Skip to content

Commit

Permalink
Merge branch 'meta-llama:main' into fix/llm-finetuning-links
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorKasianenko authored Feb 6, 2025
2 parents 691bcce + 31a951a commit bd5d2da
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
30 changes: 30 additions & 0 deletions end-to-end-use-cases/coding/text2sql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Text2SQL: Natural Language to SQL Interface

This project provides a set of scripts to convert natural language queries into SQL statements using Meta's Llama model. The goal is to enable users to interact with databases using natural language inputs, making it easier for non-technical users to access and analyze data.

For detailed instructions on setting up the environment, creating a database, and executing natural language queries using the Text2SQL interface, please refer to the quickstart.ipynb notebook.

### Structure:

- quickstart.ipynb: A Quick Demo of Text2SQL Using Llama 3.3. This Jupyter Notebook includes examples of how to use the interface to execute natural language queries on the sample data. It uses Llama 3.3 to answer questions about a SQLite database using LangChain and the Llama cloud provider Together.ai.
- nba.txt: A text file containing NBA roster information, which is used as sample data for demonstration purposes.
- txt2csv.py: A script that converts text data into a CSV format. This script is used to preprocess the input data before it is fed into csv2db.py.
- csv2db.py: A script that imports data from a CSV file into a SQLite database. This script is used to populate the database with sample data.
- nba_roster.db: A SQLite database file created from the nba.txt data, used to test the Text2SQL interface.

### Detailed steps on running the notebook:

- Before getting started, please make sure to setup Together.ai and get an API key from [here](https://www.together.ai/).

- First, please install the requirements from [here](https://github.com/meta-llama/llama-cookbook/blob/main/end-to-end-use-cases/coding/text2sql/requierements.txt) by running inside the folder:

```
git clone https://github.com/meta-llama/llama-cookbook.git
cd llama-cookbook/end-to-end-use-cases/coding/text2sql/
pip install -r requirements.txt
```

### Contributing
Contributions are welcome! If you'd like to add new features or improve existing ones, please submit a pull request. We encourage contributions in the following areas:
- Adding support for additional databases
- Developing new interfaces or applications that use the Text2SQL interface
4 changes: 2 additions & 2 deletions end-to-end-use-cases/coding/text2sql/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"\n",
"This demo shows how to use Llama 3.3 to answer questions about a SQLite DB. \n",
"\n",
"We'll use LangChain and the Llama cloud provider [Together.ai](https://api.together.ai/), where you can easily get a free API key (or you can use any other Llama cloud provider or even Ollama running Llama locally - see [here](https://github.com/meta-llama/llama-recipes/tree/main/recipes/quickstart) for examples)."
"We'll use LangChain and the Llama cloud provider [Together.ai](https://api.together.ai/), where you can easily get a free API key (or you can use any other Llama cloud provider or even Ollama running Llama locally)."
]
},
{
Expand All @@ -21,7 +21,7 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install -U langchain langchain-community langchain-together"
"!pip install --upgrade -r requirements.txt"
]
},
{
Expand Down
3 changes: 3 additions & 0 deletions end-to-end-use-cases/coding/text2sql/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
langchain
langchain-community
langchain-together

0 comments on commit bd5d2da

Please sign in to comment.