Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Update documentation to clarify that passing string prompts to LLM pipeline requires applying chat templates

davidmezzetti846fbaf3778f
diff --git a/docs/pipeline/text/llm.md b/docs/pipeline/text/llm.md
index a66d36fd..82f27b01 100644
--- a/docs/pipeline/text/llm.md
+++ b/docs/pipeline/text/llm.md
@@ -29,6 +29,17 @@ llm(
"""
)
+# Instruction tuned models typically require string prompts to
+# follow a specific chat template set by the model
+llm("""
+ <|im_start|>system
+ You are a friendly assistant.<|im_end|>
+ <|im_start|>user
+ Answer the following question...<|im_end|>
+ <|im_start|>assistant
+"""
+)
+
# Chat messages are also supported
llm([
{"role": "system", "content": "You are a friendly assistant."},
diff --git a/src/python/txtai/pipeline/llm/generation.py b/src/python/txtai/pipeline/llm/generation.py
index 34d22789..371d57e8 100644
--- a/src/python/txtai/pipeline/llm/generation.py
+++ b/src/python/txtai/pipeline/llm/generation.py
@@ -28,7 +28,7 @@ class Generation:
"""
Generates text. Supports the following input formats:
- - String or list of strings
+ - String or list of strings (instruction-tuned models must follow chat templates)
- List of dictionaries with `role` and `content` key-values or lists of lists
Args:
diff --git a/src/python/txtai/pipeline/llm/huggingface.py b/src/python/txtai/pipeline/llm/huggingface.py
index c2769800..833903bd 100644
--- a/src/python/txtai/pipeline/llm/huggingface.py
+++ b/src/python/txtai/pipeline/llm/huggingface.py
@@ -45,7 +45,7 @@ class HFLLM(HFPipeline):
"""
Generates text. Supports the following input formats:
- - String or list of strings
+ - String or list of strings (instruction-tuned models must follow chat templates)
- List of dictionaries with `role` and `content` key-values or lists of lists
Args:
diff --git a/src/python/txtai/pipeline/llm/llm.py b/src/python/txtai/pipeline/llm/llm.py
index 22779b2c..91d65456 100644
--- a/src/python/txtai/pipeline/llm/llm.py
+++ b/src/python/txtai/pipeline/llm/llm.py
@@ -42,7 +42,7 @@ class LLM(Pipeline):
"""
Generates text. Supports the following input formats:
- - String or list of strings
+ - String or list of strings (instruction-tuned models must follow chat templates)
- List of dictionaries with `role` and `content` key-values or lists of lists
Args: