You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: extension/llm/runner/README.md
+117Lines changed: 117 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,6 +164,123 @@ int main() {
164
164
}
165
165
```
166
166
167
+
## Python API
168
+
169
+
The LLM Runner framework also provides Python bindings for easy integration with Python applications. The Python API mirrors the C++ interface while providing Pythonic convenience features.
170
+
171
+
### Installation
172
+
173
+
Build the Python bindings as part of the ExecuTorch build:
174
+
175
+
```bash
176
+
# Build with Python bindings enabled
177
+
cmake -DPYTHON_EXECUTABLE=$(which python3) \
178
+
-DEXECUTORCH_BUILD_EXTENSION_LLM=ON \
179
+
-DEXECUTORCH_BUILD_PYTHON_BINDINGS=ON \
180
+
..
181
+
make -j8 _llm_runner
182
+
```
183
+
184
+
### Quick Start - Python
185
+
186
+
```python
187
+
import _llm_runner
188
+
import numpy as np
189
+
190
+
# Create a multimodal runner
191
+
runner = _llm_runner.MultimodalRunner(
192
+
model_path="/path/to/model.pte",
193
+
tokenizer_path="/path/to/tokenizer.bin"
194
+
)
195
+
196
+
# Create multimodal inputs
197
+
inputs = []
198
+
199
+
# Add text input
200
+
inputs.append(_llm_runner.make_text_input("Describe this image:"))
0 commit comments