generate#
Generates text from a prompt using a local LLM. The model can be a mock model id, a local path to an ONNX model directory, or a HuggingFace repository id (which is automatically downloaded and converted).
Usage#
python -m locodellm generate MODEL PROMPT [OPTIONS]
Options#
MODELModel id or path. Use
mock/generatefor the mock model, a local directory path, or a HuggingFace id likeQwen/Qwen2.5-Coder-0.5B-Instruct.PROMPTThe prompt text to send to the model.
--precisionPrecision qualifier for conversion (e.g.
fp32,fp16,int4).--providerExecution provider (e.g.
CUDAExecutionProvider).--max-lengthMaximum token length for generation (default: 200).
--chat-templateChat template to use (e.g.
chatml).--verbose, -vVerbosity level (default: 0).
Examples#
Using the mock model:
python -m locodellm generate mock/generate \
'write a python function which returns "hello"' --chat-template chatml
Output:
Here's a simple Python function that returns "hello":
```python
def hello():
return "hello"
```
You can call this function and it will return the string "hello".
Using a HuggingFace model (automatically downloaded and converted):
python -m locodellm generate Qwen/Qwen2.5-Coder-0.5B-Instruct \
'write a python function which returns "hello"' \
--chat-template chatml --precision fp32 --verbose 1