diff --git a/docs/source/conceptual/guidance.md b/docs/source/conceptual/guidance.md index 0a3bbd60..a9ff61d8 100644 --- a/docs/source/conceptual/guidance.md +++ b/docs/source/conceptual/guidance.md @@ -1,6 +1,6 @@ # Guidance -Text Generation Inference (TGI) now supports [JSON and regex grammars](#grammar-and-constraints) and [tools and functions](#tools-and-functions) to help developer guide LLM responses to fit their needs. +Text Generation Inference (TGI) now supports [JSON and regex grammars](#grammar-and-constraints) and [tools and functions](#tools-and-functions) to help developers guide LLM responses to fit their needs. These feature are available starting from version `1.4.3`. They are accessible via the [text_generation](https://pypi.org/project/text-generation/) library and is compatible with OpenAI's client libraries. The following guide will walk you through the new features and how to use them! @@ -16,7 +16,7 @@ If you're not up to date, grab the latest version and let's get started! - [The Grammar Parameter](#the-grammar-parameter): Shape your AI's responses with precision. - [Constrain with Pydantic](#constrain-with-pydantic): Define a grammar using Pydantic models. -- [JSON Schema Integration](#json-schema-integration): Fine grain control over your requests via JSON schema. +- [JSON Schema Integration](#json-schema-integration): Fine-grained control over your requests via JSON schema. - [Using the client](#using-the-client): Use TGI's client libraries to shape the AI's responses. ### Tools and Functions @@ -72,9 +72,9 @@ curl localhost:3000/generate \ ``` -A grammar can be defined using Pydantic models, JSON schema, or regular expressions. The AI will then generate a response that conforms to the specified grammar. +A grammar can be defined using Pydantic models, JSON schemas, or regular expressions. The AI will then generate a response that conforms to the specified grammar. -> Note: A grammar must compile to a intermediate representation to constrain the output. Grammar compilation is a computationally expensive and may take a few seconds to complete on the first request. Subsequent requests will use the cached grammar and will be much faster. +> Note: A grammar must compile to an intermediate representation to constrain the output. Grammar compilation is a computationally expensive and may take a few seconds to complete on the first request. Subsequent requests will use the cached grammar and will be much faster. ### Constrain with Pydantic @@ -151,7 +151,7 @@ json_schema = { } data = { - "inputs": "[INST]convert to JSON: I saw a puppy a cat and a raccoon during my bike ride in the park [/INST]", + "inputs": "convert to JSON: I saw a puppy a cat and a raccoon during my bike ride in the park", "parameters": { "max_new_tokens": 200, "repetition_penalty": 1.3, diff --git a/docs/source/conceptual/speculation.md b/docs/source/conceptual/speculation.md index 071b7b68..f306c48a 100644 --- a/docs/source/conceptual/speculation.md +++ b/docs/source/conceptual/speculation.md @@ -36,7 +36,7 @@ In order to use medusa models in TGI, simply point to a medusa enabled model, an If you don't have a medusa model, or don't have the resource to fine-tune, you can try to use `n-gram`. -Ngram works by trying to find in the previous sequence existing tokens that match, and use those as speculation. +N-gram works by trying to find matching tokens in the previous sequence, and use those as speculation for generating new tokens. For example, if the tokens "np.mean" appear multiple times in the sequence, the model can speculate that the next continuation of the tokens "np." is probably also "mean". This is an extremely simple method, which works best for code, or highly repetitive text. This might not be beneficial, if the speculation misses too much. diff --git a/docs/source/conceptual/streaming.md b/docs/source/conceptual/streaming.md index 505a0d9e..71ec9b25 100644 --- a/docs/source/conceptual/streaming.md +++ b/docs/source/conceptual/streaming.md @@ -15,7 +15,7 @@ Token streaming is the mode in which the server returns the tokens one by one as /> -With token streaming, the server can start returning the tokens one by one before having to generate the whole response. Users can have a sense of the generation's quality earlier than the end of the generation. This has different positive effects: +With token streaming, the server can start returning the tokens one by one before having to generate the whole response. Users can have a sense of the generation's quality before the end of the generation. This has different positive effects: * Users can get results orders of magnitude earlier for extremely long queries. * Seeing something in progress allows users to stop the generation if it's not going in the direction they expect. @@ -116,7 +116,7 @@ curl -N 127.0.0.1:8080/generate_stream \ First, we need to install the `@huggingface/inference` library. `npm install @huggingface/inference` -If you're using the free Inference API, you can use `HfInference`. If you're using inference endpoints, you can use `HfInferenceEndpoint`. Let's +If you're using the free Inference API, you can use `HfInference`. If you're using inference endpoints, you can use `HfInferenceEndpoint`. We can create a `HfInferenceEndpoint` providing our endpoint URL and credential. diff --git a/docs/source/index.md b/docs/source/index.md index 8bf45dce..309442b1 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -18,8 +18,8 @@ Text Generation Inference implements many optimizations and features, such as: - Logits warper (temperature scaling, top-p, top-k, repetition penalty) - Stop sequences - Log probabilities -- Custom Prompt Generation: Easily generate text by providing custom prompts to guide the model's output. - Fine-tuning Support: Utilize fine-tuned models for specific tasks to achieve higher accuracy and performance. +- [Guidance](../conceptual/guidance): Enable function calling and tool-use by forcing the model to generate structured outputs based on your own predefined output schemas. Text Generation Inference is used in production by multiple projects, such as: