RoboZoom
Using Bumblebee for Text Generation
I’m brand new to AI and using NX/Bumblebee. I have attempted to adapt this example from the bumblebee docs to generate a narrative description of a kids math problem using GPT 2:
def make_story_question(%MathQuiz.Models.MathQuizItem{} = question) do
model_name = "openai-community/gpt2"
{:ok, granite} = Bumblebee.load_model({:hf, model_name})
{:ok, tokenizer} = Bumblebee.load_tokenizer({:hf, model_name})
{:ok, generation_config} = Bumblebee.load_generation_config({:hf, model_name})
serving = Bumblebee.Text.generation(granite, tokenizer, generation_config)
question_prompt =
"Write a narrative story question for children for the math problem #{question.first_num} plus #{question.second_num}."
|> IO.inspect(label: "Prompt")
# text_input = Kino.Input.text(question_prompt, default: "Tomorrow it will be")
# text = Kino.Input.read(text_input)
Nx.Serving.run(serving, question_prompt)
end
When I run the code above, this function never completes (even after 10 minutes) on a moderately performant desktop. An example output on the text prompt is:
Prompt: “Write a narrative story question for children for the math problem 3 plus 3.”
I suspect that the Nx.Serving.run command is likely opening a server, and never closing. How do I get this function to get the response from the model? Am I doing something stupid basic wrong?
Marked As Solved
polvalente
I’m not sure why you’re getting a stream out of your function, but I suspect it has to do with stream: true. Try removing that for now, or calling Enum.to_list on the output of batched_run. Definitely open an issue so that we can improve documentation!
The rest of the code looks correct.
Regarding architectures, Bumblebee has a set of supported architectures. I don’t recall if that’s documented, or if you need to open the codebase to get the list.
Also Liked
RoboZoom
I can’t believe I missed the stream configuration - tells you I’m working on this side project when I’m way to tired.
I was able to get the app to function - the GPT model just gave me a bunch of bogus references to what looked like malware sites and a plea to ask questions about bitcoin instead. But now I can work to get new models integrated that provide more appropriate responses.
I’m happy to contribute to support documentation - least I can do is to help with writing as a newcomer to the space. Thanks for all of the help above.
Last Post!
RoboZoom
I can’t believe I missed the stream configuration - tells you I’m working on this side project when I’m way to tired.
I was able to get the app to function - the GPT model just gave me a bunch of bogus references to what looked like malware sites and a plea to ask questions about bitcoin instead. But now I can work to get new models integrated that provide more appropriate responses.
I’m happy to contribute to support documentation - least I can do is to help with writing as a newcomer to the space. Thanks for all of the help above.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









