#Summarize text with Bumblebee

6 messages · Page 1 of 1 (latest)

foggy hedge
#

Hello all, I want to summarize a text with bart-large-cnn but I cant find any up to date documentation on how to do it. All the infos I find online seems to be outdated. This is my code:

  def summarize_text(text) do
    # Load the BART model for summarization
    {:ok, model_info} = Bumblebee.load_model({:hf, "facebook/bart-large-cnn"})
    {:ok, tokenizer} = Bumblebee.load_tokenizer({:hf, "facebook/bart-large-cnn"})
    {:ok, generation_config} = Bumblebee.load_generation_config({:hf, "facebook/bart-large-cnn"})

    generation_config = Bumblebee.configure(generation_config, max_new_tokens: 100)


    serving =
      Bumblebee.Text.generation(model_info, tokenizer, generation_config,
        compile: [batch_size: 1, sequence_length: 512],
        defn_options: [
          compiler: EXLA,
          cache: Path.join(System.tmp_dir!(), "bumblebee_examples/text_summarization")
        ]
      )

    # Generate summary
    {:ok, result} = Nx.Serving.run(serving, %{text: text})
    summary = Enum.map(result.results, fn r -> r.text end) |> Enum.join(" ")

    summary
  end

thats the error

Yts.Audio.summarize_text("Elixir leverages the Erlang VM, known for running low-latency, distributed, and fault-tolerant systems. Elixir is successfully used in web development, embedded software, data ingestion, and multimedia processing, across a wide range of industries")
[debug] the following parameters were missing:

  * language_modeling_head.logits_bias.bias

W0000 00:00:1743201754.366949   53443 onednn_matmul.cc:319] [Perf]: MatMul reference implementation being executed                                                ** (MatchError) no match of right hand side value: %{results: [%{text: "The first time a person seess when a person is looking for a place to go to a nightclub.", token_summary: %{input: 53, output: 89, padding: 459}}]}
    (yts 0.1.0) lib/yts/audio.ex:51: Yts.Audio.summarize_text/1
    iex:35: (file)
delicate crater
#

What's line 51 in audio.ex?

#

Seems that Nx.Serving.run is returning the result directly and not in a ok-tuple so your match fails

#

I don't know what the part about missing parameters is

foggy hedge
#

This can be closed/removed now