Text Generation
Transformers
Safetensors
Greek
llama
greek
instruction-tuned
conversational
text-generation-inference
Instructions to use ComputationalLinguisticsPlatform/LexisLM-1B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ComputationalLinguisticsPlatform/LexisLM-1B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ComputationalLinguisticsPlatform/LexisLM-1B-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ComputationalLinguisticsPlatform/LexisLM-1B-Instruct") model = AutoModelForCausalLM.from_pretrained("ComputationalLinguisticsPlatform/LexisLM-1B-Instruct", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ComputationalLinguisticsPlatform/LexisLM-1B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ComputationalLinguisticsPlatform/LexisLM-1B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ComputationalLinguisticsPlatform/LexisLM-1B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ComputationalLinguisticsPlatform/LexisLM-1B-Instruct
- SGLang
How to use ComputationalLinguisticsPlatform/LexisLM-1B-Instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ComputationalLinguisticsPlatform/LexisLM-1B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ComputationalLinguisticsPlatform/LexisLM-1B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ComputationalLinguisticsPlatform/LexisLM-1B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ComputationalLinguisticsPlatform/LexisLM-1B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ComputationalLinguisticsPlatform/LexisLM-1B-Instruct with Docker Model Runner:
docker model run hf.co/ComputationalLinguisticsPlatform/LexisLM-1B-Instruct
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -9,7 +9,7 @@ tags:
|
|
| 9 |
- text-generation
|
| 10 |
- instruction-tuned
|
| 11 |
- llama
|
| 12 |
-
base_model:
|
| 13 |
---
|
| 14 |
|
| 15 |
# LexisLM-1B-Instruct
|
|
@@ -34,20 +34,36 @@ The chat template prepends `<eos>`, formats each message as `<|role|>` followed
|
|
| 34 |
## Usage
|
| 35 |
|
| 36 |
```python
|
|
|
|
| 37 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 38 |
|
| 39 |
-
model_id = "
|
| 40 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
inputs = tokenizer.apply_chat_template(
|
| 44 |
messages, add_generation_prompt=True, tokenize=True,
|
| 45 |
return_tensors="pt", return_dict=True,
|
| 46 |
-
)
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
print(tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
| 49 |
```
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
## Evaluation
|
| 52 |
|
| 53 |
|
|
|
|
| 9 |
- text-generation
|
| 10 |
- instruction-tuned
|
| 11 |
- llama
|
| 12 |
+
base_model: Konstantinos/LexisLM-1B
|
| 13 |
---
|
| 14 |
|
| 15 |
# LexisLM-1B-Instruct
|
|
|
|
| 34 |
## Usage
|
| 35 |
|
| 36 |
```python
|
| 37 |
+
import torch
|
| 38 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 39 |
|
| 40 |
+
model_id = "ComputationalLinguisticsPlatform/LexisLM-1B-Instruct"
|
| 41 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 42 |
+
torch.set_num_threads(4)
|
| 43 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32)
|
| 44 |
+
torch.manual_seed(42)
|
| 45 |
+
messages = [{"role": "user", "content": "Η πρωτεύουσα της Ελλάδας είναι"}]
|
| 46 |
inputs = tokenizer.apply_chat_template(
|
| 47 |
messages, add_generation_prompt=True, tokenize=True,
|
| 48 |
return_tensors="pt", return_dict=True,
|
| 49 |
+
)
|
| 50 |
+
inputs = {key: value.to(model.device) for key, value in inputs.items()
|
| 51 |
+
if key in ("input_ids", "attention_mask")}
|
| 52 |
+
output = model.generate(
|
| 53 |
+
**inputs, max_new_tokens=64, do_sample=True, temperature=0.1, top_p=0.9,
|
| 54 |
+
eos_token_id=[tokenizer.eos_token_id,
|
| 55 |
+
tokenizer.convert_tokens_to_ids("<|endofturn|>")],
|
| 56 |
+
pad_token_id=tokenizer.pad_token_id,
|
| 57 |
+
)
|
| 58 |
print(tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
| 59 |
```
|
| 60 |
|
| 61 |
+
Output from this example (CPU FP32, seed 42):
|
| 62 |
+
|
| 63 |
+
```text
|
| 64 |
+
Η Αθήνα είναι η πρωτεύουσα της Ελλάδας από το 1834.
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
## Evaluation
|
| 68 |
|
| 69 |
|