Langroid: Chat to a CSV file using Mixtral (via Ollama)
HTML-код
- Опубликовано: 6 сен 2024
- In this video, we'll learn about Langroid, an interesting LLM library that amongst other things, lets us query tabular data, including CSV files! It delegates part of the work to an LLM of your choice under the hood, and I decided to take it for a spin using Kaggle's world population dataset. We give it three different questions to answer and then I write Pandas code to check the results. The results are sometimes good, sometimes downright hallucinations!
#pandas #llm #mixtral #litellm #ollama
Resources
Langroid - github.com/lan...
litellm - litellm.ai/
Mixtral (via Ollama) - ollama.ai/
World population data - www.kaggle.com...
Code - github.com/mne...
This kind of pandas test looks like a great way to look at and compare various models, for example comparing the same automated test and collecting results to compare.
That's a great idea. I guess itd be interesting to compare this type of tool vs the fine tuned coding models
Nice video (as always!)
Shame it was hallucinating results - would be interesting to get to the bottom of that, perhaps with other csv datasets and/or debugging what langdroid is actually doing.
Yeh, I need to look into that more. I found that with the example CSV file provided in the Langroid docs it was working pretty well, but I wanted to try it with something a bit more random to see if its performance generalised!
Another issue i think is code readability, the code for calculating population change generated by LLM is a bit unnecessarily complex, maybe because its trying to fit the whole operation in a single line......still its impressive how its actually able to understand Column/feature meaning 👏
Yeh I liked that too as usually if you give an LLM a table it comes up with gibberish in response!
🎯 Key Takeaways for quick navigation:
00:00 📚 *Introduction to Langroid*
- Langroid is an LLM library for querying tabular data like CSV files.
- Setting up Langroid involves configuring the LLM, initializing the agent, and creating a task.
- Quick check with a question about pandas to ensure Langroid is working.
01:11 🗃️ *Loading and Exploring CSV Data*
- Importing a world population dataset from Kaggle using pandas.
- Displaying and exploring the dataset columns and content.
- Configuring Langroid to query the CSV file for specific information.
02:22 ⚙️ *Running Langroid Tasks and Analyzing Results*
- Creating a task to find the top five countries by population.
- Discussing the iteration limit and the time it takes for Mixt to load.
- Analyzing Langroid's generated code and results for the top countries.
03:30 📈 *Comparing Langroid's Answers with Pandas*
- Comparing Langroid's answer for the biggest population increase with a manual pandas approach.
- Highlighting discrepancies in the results and questioning Langroid's accuracy.
- Discussing potential reasons for incorrect Langroid answers.
04:53 🌐 *Grouping and Aggregating Data with Langroid*
- Formulating a complex question about the average, minimum, and maximum area for each continent.
- Running Langroid to answer the question and examining the results.
- Contrasting Langroid's answers with manually obtained accurate results using pandas.
Made with HARPA AI
Neat - that sounds like a clever tool!
Is langroid only good for querying data? Surely, you can define new tools, so that it can do anything any of the other frameworks can do? Generating code etc.
Yep you can define your own tools. I haven't tried that out to see how well it works yet.
@@learndatawithmark trying to figure it out now, with a 2 agent solution for following a list of instructions. Will let you know how it goes.
works good just cant get the doc chat agent working with a local llm any ideas on how i could fix that
Yeh, same here! I tried the doc chat agent first and it just sat there spinning for ages, which is why I moved onto the CSV file based one instead.
@@learndatawithmark hey I actually got the doc chat agent to work as well with a local llm if you want I can share my code here.
Which of the many do you recommend? Langgraph?
I've played with Langroid and CrewAI and neither worked that well. I haven't tried AutoGen or LangGrfaph yet, but I guess I should get on it!
import langroid.language_models as lm → ModuleNotFoundError: No module named 'langroid.language_models'; 'langroid' is not a package
:(
You definitely installed the langroid package with pip install langroid? Try doing import langroid to check?
@@learndatawithmarkyes langroid was installed via pip
So in the video I installed everything in a Python virtual env:
python -m venv .venv
source .venv/bin/activate
I did also try with Poetry, but I was having problems when I did that. I dunno if you're already using a virtual env, but might be worth trying if not?
hey bro you should make sure your using the right version of python i would use 3.11.3