Skip to content

Commit

Permalink
Removing old research directory, adding new
Browse files Browse the repository at this point in the history
  • Loading branch information
parkervg committed Oct 18, 2024
1 parent 230bbab commit b341e88
Show file tree
Hide file tree
Showing 75 changed files with 222 additions and 12,328 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,15 @@ For in-depth descriptions of the above queries, check out our [documentation](ht
```python
import pandas as pd

from blendsql import blend, LLMMap, LLMQA, LLMJoin
import blendsql
from blendsql.ingredients import LLMMap, LLMQA, LLMJoin
from blendsql.db import Pandas
from blendsql.models import TransformersLLM, OpenaiLLM

# Optionally set how many async calls to allow concurrently
# This depends on your OpenAI/Anthropic/etc. rate limits
blendsql.config.set_async_limit(10)

# Load model
# model = OpenaiLLM("gpt-4o") # If you have a .env present with OpenAI API keys
model = TransformersLLM('Qwen/Qwen1.5-0.5B')
Expand Down Expand Up @@ -190,7 +195,7 @@ db = Pandas(
)

# Write BlendSQL query
blendsql = """
query = """
SELECT * FROM w
WHERE city = {{
LLMQA(
Expand All @@ -200,8 +205,8 @@ WHERE city = {{
)
}}
"""
smoothie = blend(
query=blendsql,
smoothie = blendsql.blend(
query=query,
db=db,
ingredients={LLMMap, LLMQA, LLMJoin},
default_model=model,
Expand Down
3 changes: 2 additions & 1 deletion blendsql/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .ingredients.builtin import LLMMap, LLMQA, LLMJoin, LLMValidate, ImageCaption
from .blend import blend
from .ingredients import LLMQA, LLMMap, LLMJoin, LLMValidate, ImageCaption
from . import _configure as config
69 changes: 37 additions & 32 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,47 @@ hide:
```python
import pandas as pd

from blendsql import blend, LLMMap, LLMQA, LLMJoin
import blendsql
from blendsql.ingredients import LLMMap, LLMQA, LLMJoin
from blendsql.db import Pandas
from blendsql.models import TransformersLLM, OpenaiLLM

# Optionally set how many async calls to allow concurrently
# This depends on your OpenAI/Anthropic/etc. rate limits
blendsql.config.set_async_limit(10)

# Load model
# model = OpenaiLLM("gpt-4o") # If you have a .env present with OpenAI API keys
model = TransformersLLM('Qwen/Qwen1.5-0.5B')

# Prepare our local database
db = Pandas(
{
"w": pd.DataFrame(
(
['11 jun', 'western districts', 'bathurst', 'bathurst ground', '11-0'],
['12 jun', 'wallaroo & university nsq', 'sydney', 'cricket ground',
'23-10'],
['5 jun', 'northern districts', 'newcastle', 'sports ground', '29-0']
),
columns=['date', 'rival', 'city', 'venue', 'score']
),
"documents": pd.DataFrame(
(
['bathurst, new south wales',
'bathurst /ˈbæθərst/ is a city in the central tablelands of new south wales , australia . it is about 200 kilometres ( 120 mi ) west-northwest of sydney and is the seat of the bathurst regional council .'],
['sydney',
'sydney ( /ˈsɪdni/ ( listen ) sid-nee ) is the state capital of new south wales and the most populous city in australia and oceania . located on australia s east coast , the metropolis surrounds port jackson.'],
['newcastle, new south wales',
'the newcastle ( /ˈnuːkɑːsəl/ new-kah-səl ) metropolitan area is the second most populated area in the australian state of new south wales and includes the newcastle and lake macquarie local government areas .']
),
columns=['title', 'content']
)
}
{
"w": pd.DataFrame(
(
['11 jun', 'western districts', 'bathurst', 'bathurst ground', '11-0'],
['12 jun', 'wallaroo & university nsq', 'sydney', 'cricket ground',
'23-10'],
['5 jun', 'northern districts', 'newcastle', 'sports ground', '29-0']
),
columns=['date', 'rival', 'city', 'venue', 'score']
),
"documents": pd.DataFrame(
(
['bathurst, new south wales',
'bathurst /ˈbæθərst/ is a city in the central tablelands of new south wales , australia . it is about 200 kilometres ( 120 mi ) west-northwest of sydney and is the seat of the bathurst regional council .'],
['sydney',
'sydney ( /ˈsɪdni/ ( listen ) sid-nee ) is the state capital of new south wales and the most populous city in australia and oceania . located on australia s east coast , the metropolis surrounds port jackson.'],
['newcastle, new south wales',
'the newcastle ( /ˈnuːkɑːsəl/ new-kah-səl ) metropolitan area is the second most populated area in the australian state of new south wales and includes the newcastle and lake macquarie local government areas .']
),
columns=['title', 'content']
)
}
)

# Write BlendSQL query
blendsql = """
query = """
SELECT * FROM w
WHERE city = {{
LLMQA(
Expand All @@ -52,14 +57,14 @@ WHERE city = {{
)
}}
"""
smoothie = blend(
query=blendsql,
db=db,
ingredients={LLMMap, LLMQA, LLMJoin},
default_model=model,
# Optional args below
infer_gen_constraints=True,
verbose=True
smoothie = blendsql.blend(
query=query,
db=db,
ingredients={LLMMap, LLMQA, LLMJoin},
default_model=model,
# Optional args below
infer_gen_constraints=True,
verbose=True
)
print(smoothie.df)
# ┌────────┬───────────────────┬──────────┬─────────────────┬─────────┐
Expand Down
1 change: 1 addition & 0 deletions research/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data/
Loading

0 comments on commit b341e88

Please sign in to comment.