Skip to content

armgit / txtai

Public Imported from GitHub
0

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

LiteRT updates

davidmezzetti7ff55f32f779
diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile
index e04b8eb1..4fff2466 100644
--- a/docker/base/Dockerfile
+++ b/docker/base/Dockerfile
@@ -21,7 +21,7 @@ ENV LANG=C.UTF-8
RUN \
# Install required packages
apt-get update && \
- apt-get -y --no-install-recommends install libgomp1 libportaudio2 libsndfile1 git gcc g++ python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python3-pip && \
+ apt-get -y --no-install-recommends install libgomp1 libportaudio2 libsndfile1 libegl1 libgles2 libvulkan1 git gcc g++ python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python3-pip && \
rm -rf /var/lib/apt/lists && \
\
# Install txtai project and dependencies
diff --git a/docs/install.md b/docs/install.md
index b3a8d289..01e703c0 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -130,7 +130,11 @@ Additional environment specific prerequisites are below.
### Linux
-The AudioStream and Microphone pipelines require the [PortAudio](https://python-sounddevice.readthedocs.io/en/0.5.0/installation.html) system library. The Transcription pipeline requires the [SoundFile](https://github.com/bastibe/python-soundfile#installation) system library. The LiteRT LLM pipeline requires libegl1 and libgles2.
+The AudioStream and Microphone pipelines require the [PortAudio](https://python-sounddevice.readthedocs.io/en/0.5.0/installation.html) system library.
+
+The Transcription pipeline requires the [SoundFile](https://github.com/bastibe/python-soundfile#installation) system library.
+
+The LiteRT LLM pipeline requires libegl1, libgles2 and libvulkan1.
### macOS
diff --git a/docs/pipeline/llm/llm.md b/docs/pipeline/llm/llm.md
index f2a52108..72b6044e 100644
--- a/docs/pipeline/llm/llm.md
+++ b/docs/pipeline/llm/llm.md
@@ -63,9 +63,14 @@ The LLM pipeline automatically detects the underlying LLM framework. This can al
- [Hugging Face Transformers](https://github.com/huggingface/transformers)
- [llama.cpp](https://github.com/abetlen/llama-cpp-python)
- [LLM APIs via LiteLLM](https://github.com/BerriAI/litellm)
+- [LiteRT-LM](https://ai.google.dev/edge/litert-lm)
- [OpenCode server](https://github.com/anomalyco/opencode)
-`llama.cpp` models support both local and remote GGUF paths on the HF Hub. See the [LiteLLM documentation](https://litellm.vercel.app/docs/providers) for the options available with LiteLLM models. See the [OpenCode documentation](https://opencode.ai/docs/server/) for more on how to integrate the LLM pipeline with a running OpenCode instance.
+`llama.cpp` and `LiteRT-LM` support both local and remote file paths on the HF Hub.
+
+See the [LiteLLM documentation](https://litellm.vercel.app/docs/providers) for the options available with LiteLLM models.
+
+See the [OpenCode documentation](https://opencode.ai/docs/server/) for more on how to integrate the LLM pipeline with a running OpenCode instance.
```python
from txtai import LLM
@@ -83,6 +88,15 @@ llm = LLM("unsloth/gpt-oss-20b-GGUF/gpt-oss-20b-Q4_K_M.gguf",
llm = LLM("ollama/gpt-oss")
llm = LLM("ollama/gpt-oss", method="litellm")
+# LiteRT-LM
+llm = LLM(
+ "litert-community/gemma-4-E2B-it-litert-lm/gemma-4-E2B-it.litertlm"
+)
+llm = LLM(
+ "litert-community/gemma-4-E2B-it-litert-lm/gemma-4-E2B-it.litertlm",
+ method="litert"
+)
+
# Custom Ollama endpoint
llm = LLM("ollama/gpt-oss", api_base="http://localhost:11434")
diff --git a/src/python/txtai/pipeline/llm/litert.py b/src/python/txtai/pipeline/llm/litert.py
index 7bee25e9..bc7d5695 100644
--- a/src/python/txtai/pipeline/llm/litert.py
+++ b/src/python/txtai/pipeline/llm/litert.py
@@ -83,7 +83,7 @@ class LiteRT(Generation):
return litert_lm.Engine(
path,
backend=litert_lm.Backend.GPU if gpu else litert_lm.Backend.CPU,
- enable_speculative_decoding=gpu,
+ enable_speculative_decoding=kwargs.get("mtp", gpu),
max_num_tokens=kwargs.get("maxlength"),
)
diff --git a/test/python/testpipeline/testllm/testlitert.py b/test/python/testpipeline/testllm/testlitert.py
index c7417be0..726822eb 100644
--- a/test/python/testpipeline/testllm/testlitert.py
+++ b/test/python/testpipeline/testllm/testlitert.py
@@ -20,10 +20,14 @@ class TestLiteRT(unittest.TestCase):
"""
# Test model generation with LiteRT
- model = LLM("litert-community/gemma-4-E2B-it-litert-lm/gemma-4-E2B-it.litertlm")
+ model = LLM("neuml/gemma-4-tiny-random-litert-lm/gemma-4-tiny-random.litertlm", mtp=False, maxlength=25)
# Test standard
self.assertIsNotNone(model("Hello"))
# Test streaming
self.assertIsNotNone(list(model("Hello", stream=True)))
+
+ # Test CPU fallback
+ model = LLM("neuml/gemma-4-tiny-random-litert-lm/gemma-4-tiny-random.litertlm", mtp=True, maxlength=25)
+ self.assertIsNotNone(model("Hello"))