Skip to content

Commit

Permalink
Documentation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
parkervg committed Feb 22, 2024
1 parent 8f9c403 commit c834041
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 16 deletions.
6 changes: 5 additions & 1 deletion blendsql/llms/local/_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@


class TransformersLLM(LLM):
"""Class for Transformers Local LLM."""
"""Class for Transformers local LLM.
Args:
model_name_or_path: Name of the model on HuggingFace, or the path to a local model
"""

def __init__(self, model_name_or_path: str, **kwargs):
try:
Expand Down
23 changes: 19 additions & 4 deletions blendsql/llms/remote/_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,22 @@ def openai_setup() -> None:


class AzureOpenaiLLM(LLM):
"""Class for OpenAI LLM API."""
"""Class for Azure OpenAI LLM API.
def __init__(self, model_name_or_path: str, **kwargs):
Args:
model_name_or_path: Name of the Azure deployment to use
env: Path to directory of .env file, or to the file itself to load as a dotfile.
Should either contain the variable `OPENAI_API_KEY`,
or all of `TENANT_ID`, `CLIENT_ID`, `CLIENT_SECRET`
"""

def __init__(self, model_name_or_path: str, env: str, **kwargs):
super().__init__(
model_name_or_path=model_name_or_path,
tokenizer=tiktoken.encoding_for_model(model_name_or_path),
requires_config=True,
refresh_interval_min=30,
env=env,
**kwargs
)

Expand All @@ -70,14 +78,21 @@ def _setup(self, **kwargs) -> None:


class OpenaiLLM(LLM):
"""Class for OpenAI LLM API."""
"""Class for OpenAI LLM API.
Args:
model_name_or_path: Name of the OpenAI model to use
env: Path to directory of .env file, or to the file itself to load as a dotfile.
Should contain the variable `OPENAI_API_KEY`
"""

def __init__(self, model_name_or_path: str, **kwargs):
def __init__(self, model_name_or_path: str, env: str, **kwargs):
super().__init__(
model_name_or_path=model_name_or_path,
tokenizer=tiktoken.encoding_for_model(model_name_or_path),
requires_config=True,
refresh_interval_min=30,
env=env,
**kwargs
)

Expand Down
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
> ```
> BlendSQL makes sure to only pass those `team` values from rows which satisfy the condition `num_championship > 3` to the LLM. Additionally, since we assume the function is deterministic, we make a single LLM call and cache the results, despite the ingredient function being used twice.
#### So I get how to write BlendSQL queries. But why would I use this over vanilla SQLite?
> Certain ingredients, like [LLMJoin](#joiningredient), will likely give seasoned SQL experts a headache at first. However, BlendSQL's real strength comes from it's use as an *intermediate representation for reasoning over structured + unstructured with LLMs*. Some examples of this can be found above [here](#more-examples-from-popular-qa-datasets).
> Certain ingredients, like [LLMJoin](reference/ingredients/join-ingredient.md), will likely give seasoned SQL experts a headache at first. However, BlendSQL's real strength comes from it's use as an *intermediate representation for reasoning over structured + unstructured with LLMs*. Some examples of this can be found [here](examples/hybridqa.md).
42 changes: 42 additions & 0 deletions docs/reference/blenders/openai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# OpenAI

!!! note

In order to use this LLM as a Blender, we expect that you have a .env file created with all auth variables.

## OpenaiLLM

::: blendsql.llms.remote._openai.OpenaiLLM
handler: python
show_source: false

### Example Usage
Given the following `.env` file in the current directory:
```text
OPENAI_API_KEY=my_api_key
```

```python
from blendsql.llms import OpenaiLLM

blender = OpenaiLLM("text-davinci-003", env=".")
```
## AzureOpenaiLLM

::: blendsql.llms.remote._openai.AzureOpenaiLLM
handler: python
show_source: false

### Example Usage
Given the following `.env` file in the current directory:
```text
TENANT_ID=my_tenant_id
CLIENT_ID=my_client_id
CLIENT_SECRET=my_client_secret
```

```python
from blendsql.llms import AzureOpenaiLLM

blender = AzureOpenaiLLM("text-davinci-003", env=".")
```
14 changes: 14 additions & 0 deletions docs/reference/blenders/transformers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Transformers

## TransformersLLM

::: blendsql.llms.local._transformers.TransformersLLM
handler: python
show_source: false

### Example Usage
```python
from blendsql.llms import TransformersLLM

blender = TransformersLLM("openai-community/gpt2")
```
3 changes: 2 additions & 1 deletion docs/reference/execute-blendsql.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Execute a BlendSQL Query
## blend()

::: blendsql.blendsql.blend
handler: python
show_source: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ingredients

![ingredients](../img/
![ingredients](../../img/
/ingredients.jpg)

Ingredients are at the core of a BlendSQL script.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 12 additions & 7 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ theme:
- scheme: default
primary: white
logo: img/blender.png
favicon: img/blender.png
features:
- content.code.copy
- header.autohide
Expand All @@ -22,6 +23,7 @@ markdown_extensions:
- def_list
- attr_list
- md_in_html
- pymdownx.details
- pymdownx.superfences


Expand All @@ -32,7 +34,7 @@ plugins:
handlers:
python:
options:
show_source: false
show_submodules: true
- search
- section-index

Expand All @@ -48,12 +50,15 @@ nav:
- Quickstart: quickstart.md
- FAQ: faq.md
- Documentation:
- blend(): reference/execute-blendsql.md
- Execute a BlendSQL Query: reference/execute-blendsql.md
- Ingredients:
- reference/ingredients.md
- MapIngredient: reference/map-ingredient.md
- QAIngredient: reference/qa-ingredient.md
- JoinIngredient: reference/join-ingredient.md
- LLMs: reference/llms.md
- reference/ingredients/ingredients.md
- MapIngredient: reference/ingredients/map-ingredient.md
- QAIngredient: reference/ingredients/qa-ingredient.md
- JoinIngredient: reference/ingredients/join-ingredient.md
- Blenders:
- reference/blenders/blenders.md
- OpenAI: reference/blenders/openai.md
- Transformers: reference/blenders/transformers.md
- Databases: reference/databases.md
- Technical Walkthrough: reference/technical_walkthrough.md
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def find_version(*file_paths):
"emoji==1.7.0",
],
"test": ["pytest", "huggingface_hub"],
"docs": ["mkdocstrings", "mkdocs-section-index", "mkdocs", "mkdocs-python"],
"docs": [
"mkdocs-material",
"mkdocstrings",
"mkdocs-section-index",
"mkdocstrings-python",
],
},
)

0 comments on commit c834041

Please sign in to comment.