diff --git a/docs/hub/anyscale.md b/docs/hub/anyscale.md index ebc049a..5545026 100644 --- a/docs/hub/anyscale.md +++ b/docs/hub/anyscale.md @@ -12,6 +12,12 @@ authors: # Structured Outputs with Anyscale +If you want to try this example using `instructor hub`, you can pull it by running + +```bash +instructor hub pull --slug anyscale --py > anyscale_example.py +``` + Open-source LLMS are gaining popularity, and the release of Anyscale's Mistral model has made it possible to obtain structured outputs using JSON schema at any scale. Instead of relying on a model's default output mode, you can utilize JSON schema to obtain structured outputs. This approach is a time-saving alternative to extensive prompt engineering. By the end of this blog post, you will learn how to effectively utilize the instructor at any scale. But before we proceed, let's first explore the concept of patching. diff --git a/docs/hub/index.md b/docs/hub/index.md index ecc5fe1..6964d42 100644 --- a/docs/hub/index.md +++ b/docs/hub/index.md @@ -86,7 +86,6 @@ We're looking for a bunch more hub examples, if you have a tutorial or example y - [ ] Data extraction examples - [ ] Streaming examples (Iterable and Partial) - [ ] Batch Parsing examples -- [ ] Open Examples, together, anyscale, ollama, llama-cpp, etc - [ ] Query Expansion examples - [ ] Batch Data Processing examples - [ ] Batch Data Processing examples with Cache diff --git a/docs/hub/llama-cpp-python.md b/docs/hub/llama-cpp-python.md index dec7635..3f3b987 100644 --- a/docs/hub/llama-cpp-python.md +++ b/docs/hub/llama-cpp-python.md @@ -10,6 +10,12 @@ authors: # Structured Outputs with llama-cpp-python +If you want to try this example using `instructor hub`, you can pull it by running + +```bash +instructor hub pull --slug llama-cpp-python --py > llama_cpp_python_example.py +``` + Open-source LLMS are gaining popularity, and llama-cpp-python has made the `llama-cpp` model available to obtain structured outputs using JSON schema via a mixture of [constrained sampling](https://llama-cpp-python.readthedocs.io/en/latest/#json-schema-mode) and [speculative decoding](https://llama-cpp-python.readthedocs.io/en/latest/#speculative-decoding). They also support a [OpenAI compatible client](https://llama-cpp-python.readthedocs.io/en/latest/#openai-compatible-web-server), which can be used to obtain structured output as a in process mechanism to avoid any network dependency. @@ -112,9 +118,6 @@ for extraction in extraction_stream: console.print(obj) ``` -We use LlamaPromptLookupDecoding to speed up structured output generation using speculative decoding. The draft model generates candidate tokens during generation 10 is good for GPU, 2 is good for CPU. -2. We use `instructor.Mode.JSON_SCHEMA` return a JSON schema response. -3. We use `instructor.Partial` to stream out partial models. -4. This is just a simple example of how to stream out partial models and clear the console. +We use LlamaPromptLookupDecoding to speed up structured output generation using speculative decoding. The draft model generates candidate tokens during generation 10 is good for GPU, 2 is good for CPU. 2. We use `instructor.Mode.JSON_SCHEMA` return a JSON schema response. 3. We use `instructor.Partial` to stream out partial models. 4. This is just a simple example of how to stream out partial models and clear the console. ![](../img/partial.gif) diff --git a/docs/hub/multiple_classification.md b/docs/hub/multiple_classification.md index 61254e5..1ce445b 100644 --- a/docs/hub/multiple_classification.md +++ b/docs/hub/multiple_classification.md @@ -1,3 +1,9 @@ +If you want to try outs via `instructor hub`, you can pull it by running + +```bash +instructor hub pull --slug multiple_classification --py > multiple_classification.py +``` + For multi-label classification, we introduce a new enum class and a different Pydantic model to handle multiple labels. ```python diff --git a/docs/hub/ollama.md b/docs/hub/ollama.md index 7fee094..8dcaa8c 100644 --- a/docs/hub/ollama.md +++ b/docs/hub/ollama.md @@ -11,6 +11,12 @@ authors: # Structured Outputs with Ollama +If you want to try this example using `instructor hub`, you can pull it by running + +```bash +instructor hub pull --slug ollama --py > ollama_example.py +``` + Open-source LLMS are gaining popularity, and the release of Ollama's OpenAI compatibility later it has made it possible to obtain structured outputs using JSON schema. By the end of this blog post, you will learn how to effectively utilize instructor with ollama. But before we proceed, let's first explore the concept of patching. diff --git a/docs/hub/pandas_df.md b/docs/hub/pandas_df.md index 7cafbf5..3148f49 100644 --- a/docs/hub/pandas_df.md +++ b/docs/hub/pandas_df.md @@ -1,13 +1,13 @@ # Extracting directly to a DataFrame -In this example we'll show you how to extract directly to a `pandas.DataFrame` - You can pull this example into your IDE by running the following command: ```bash instructor hub pull --slug pandas_df --py > pandas_df.py ``` +In this example we'll show you how to extract directly to a `pandas.DataFrame` + ```python from io import StringIO from typing import Annotated, Any diff --git a/docs/hub/single_classification.md b/docs/hub/single_classification.md index 955e15f..a0d3b48 100644 --- a/docs/hub/single_classification.md +++ b/docs/hub/single_classification.md @@ -1,5 +1,11 @@ # Single-Label Classification +IF you want to try this code with `instructor hub` you can pull it by running + +```bash +instructor hub pull --slug single_classification --py > single_classification.py +``` + This example demonstrates how to perform single-label classification using the OpenAI API. The example uses the `gpt-3.5-turbo` model to classify text as either `SPAM` or `NOT_SPAM`. ```python diff --git a/docs/hub/together.md b/docs/hub/together.md index 58c78f6..5fd6776 100644 --- a/docs/hub/together.md +++ b/docs/hub/together.md @@ -11,6 +11,12 @@ authors: # Structured Outputs with Together AI +If you want to try this example using `instructor hub`, you can pull it by running + +```bash +instructor hub pull --slug together --py > together_example.py +``` + Open-source LLMS are gaining popularity, and with the release of Together's Function calling models, its been easier than ever to get structured outputs. By the end of this blog post, you will learn how to effectively utilize instructor with Together AI. But before we proceed, let's first explore the concept of patching. diff --git a/mkdocs.yml b/mkdocs.yml index ea6c6c8..ba310bd 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -169,10 +169,10 @@ nav: - Single Classification Model: 'hub/single_classification.md' - Multiple Classification Model: 'hub/multiple_classification.md' - Extract Pandas Dataframes: 'hub/pandas_df.md' - - Ollama: 'hub/ollama.md' - - Llama CPP: 'hub/llama-cpp-python.md' - - Together: 'hub/together.md' - - Anyscale: 'hub/anyscale.md' + - Using Ollama: 'hub/ollama.md' + - Using Llama CPP: 'hub/llama-cpp-python.md' + - Using Together Compute: 'hub/together.md' + - Using Anyscale: 'hub/anyscale.md' - Tutorials: - Tutorials (Notebooks): 'tutorials/1-introduction.ipynb' - Tips and Tricks: 'tutorials/2-tips.ipynb'