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
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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.