RoboZoom
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?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
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
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 8 of 8 Posts
polvalente
Do you have the configuration for EXLA set? You can find it right at the top of that reference link.
RoboZoom
I did not - I added the following line to my application.ex start function:
The app ran… but the text generation was really wonky. It always provides one of two answers… either “The answer to the question is” or “No human can do this problem”.
I can keep playing with the model itself… but particularly strange (in that I don’t fully understand what’s happening under the hood) is how this process relates to the Phoenix app I’m using to present the output.
Ideally I’d like this to work in an agentic sense - I send the LLM a prompt, and it gives me a response - and that is the end of the interaction. I’ve had a few different anomalies in how this is playing out, but in a general sense… the page is not fully loading/mounting.
For reference - relevant portions of my live view file:
Is there a different way I should be evaluating the model?
polvalente
I believe your make_story_question is instantiating your model on each call. You should probably have a names serving in your application tree, calling it by name from your view.
You also likely want assign_async so that the rest of the page can load while the first model call is being evaluated
RoboZoom
I appreciate the suggestion - and I’ve been working through this.
I’ve run into two classes of problems that I’m not quite sure what is happening.
Now, I start the server as part of my supervision tree in the
application.exfile like so:The content above compiles, and appears to work.
When I run this function:
I get the following output on the terminal:
Is this expected? Looking at the batched run docs, I thought I’d get the output from the LLM (instead of a function or stream).
The second class of error is that every new model I try to bring into this (other than GPT2 from the examples) drives an error where the architecture is unrecognized - is there a resource I should read about how to translate the model documents into a coerced architecture in bumblebee? Example: openai/gpt-oss-20b
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.
joelpaulkoch
You can find the list here: bumblebee/lib/bumblebee.ex at main · elixir-nx/bumblebee · GitHub
RoboZoom
This is super helpful - thanks.
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.