Text Generation
Transformers
Safetensors
PyTorch
English
pldrllm
large-language-model
power-law-decoder-representations
power-law-graph-attention
pldr-llm
kv-cache
g-cache
kvg-cache
custom_code
Instructions to use fromthesky/PLDR-LLM-v51-110M-4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fromthesky/PLDR-LLM-v51-110M-4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="fromthesky/PLDR-LLM-v51-110M-4", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("fromthesky/PLDR-LLM-v51-110M-4", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use fromthesky/PLDR-LLM-v51-110M-4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "fromthesky/PLDR-LLM-v51-110M-4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fromthesky/PLDR-LLM-v51-110M-4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/fromthesky/PLDR-LLM-v51-110M-4
- SGLang
How to use fromthesky/PLDR-LLM-v51-110M-4 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 "fromthesky/PLDR-LLM-v51-110M-4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fromthesky/PLDR-LLM-v51-110M-4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "fromthesky/PLDR-LLM-v51-110M-4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fromthesky/PLDR-LLM-v51-110M-4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use fromthesky/PLDR-LLM-v51-110M-4 with Docker Model Runner:
docker model run hf.co/fromthesky/PLDR-LLM-v51-110M-4
Commit ·
366811c
1
Parent(s): dda3ae4
Updated readme
Browse filesBumped transformers version to 4.56.1
- README.md +21 -21
- config.json +1 -1
- requirements.txt +1 -1
README.md
CHANGED
|
@@ -14,6 +14,7 @@ tags:
|
|
| 14 |
license: apache-2.0
|
| 15 |
datasets:
|
| 16 |
- tiiuae/falcon-refinedweb
|
|
|
|
| 17 |
---
|
| 18 |
|
| 19 |
# PLDR-LLM-v51-110M-4
|
|
@@ -38,7 +39,7 @@ This model is intended to be used for research purposes. Given text as input pro
|
|
| 38 |
|
| 39 |
### Via Huggingface Transformers Library
|
| 40 |
|
| 41 |
-
PLDR-LLM has custom model support for Huggingface Transformers library. PLDR-LLM custom
|
| 42 |
|
| 43 |
Using `pipeline`:
|
| 44 |
```python
|
|
@@ -47,11 +48,13 @@ from transformers import pipeline
|
|
| 47 |
pipeline = pipeline(
|
| 48 |
task="text-generation",
|
| 49 |
model="fromthesky/PLDR-LLM-v51-110M-4",
|
| 50 |
-
device="cuda"
|
|
|
|
| 51 |
)
|
| 52 |
|
| 53 |
-
prompt=
|
| 54 |
-
|
|
|
|
| 55 |
print(output[0]["generated_text"])
|
| 56 |
```
|
| 57 |
|
|
@@ -65,21 +68,24 @@ model=AutoModelForCausalLM.from_pretrained(pretrained_model_name_or_path="fromth
|
|
| 65 |
)
|
| 66 |
tokenizer=AutoTokenizer.from_pretrained(pretrained_model_name_or_path="fromthesky/PLDR-LLM-v51-110M-4",
|
| 67 |
add_eos_token=False,
|
| 68 |
-
|
| 69 |
trust_remote_code=True
|
| 70 |
)
|
| 71 |
-
|
|
|
|
|
|
|
| 72 |
inputs = tokenizer([prompt], return_tensors="pt").to(device=device)
|
| 73 |
generated_ids = model.generate(**inputs,
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
|
| 82 |
```
|
|
|
|
| 83 |
|
| 84 |
#### PLDR-LLM specific configurations:
|
| 85 |
- `custom_G_type`: `None` for learned G values during pretraining, `'identity'` for LLM with SDPA equivalent, `'random'` for G values from a random normal distribution, `'external'` for custom G values that can be assigned after model initialization. This setting is more important for training purposes, for inference it is set in the model config.json file.
|
|
@@ -94,14 +100,8 @@ the output of the residual metric learner (metric tensor, **A**), output (**A<su
|
|
| 94 |
See config.json for other model configuration details.
|
| 95 |
|
| 96 |
#### Notes:
|
| 97 |
-
-
|
| 98 |
-
|
| 99 |
-
```python
|
| 100 |
-
git clone https://github.com/huggingface/transformers
|
| 101 |
-
cd transformers
|
| 102 |
-
pip install -e ".[dev]"
|
| 103 |
-
```
|
| 104 |
-
We also have a fork of transformers library with PLDR-LLM model support for future development. The PLDR-LLM model files are added to the library so custom model files are not necessary.
|
| 105 |
```python
|
| 106 |
git clone https://github.com/burcgokden/transformers
|
| 107 |
cd transformers
|
|
|
|
| 14 |
license: apache-2.0
|
| 15 |
datasets:
|
| 16 |
- tiiuae/falcon-refinedweb
|
| 17 |
+
library_name: transformers
|
| 18 |
---
|
| 19 |
|
| 20 |
# PLDR-LLM-v51-110M-4
|
|
|
|
| 39 |
|
| 40 |
### Via Huggingface Transformers Library
|
| 41 |
|
| 42 |
+
PLDR-LLM has custom model support for Huggingface Transformers library. PLDR-LLM with custom code is evaluated on Transformers 4.56.1 available at the time.
|
| 43 |
|
| 44 |
Using `pipeline`:
|
| 45 |
```python
|
|
|
|
| 48 |
pipeline = pipeline(
|
| 49 |
task="text-generation",
|
| 50 |
model="fromthesky/PLDR-LLM-v51-110M-4",
|
| 51 |
+
device="cuda", # or "cpu"
|
| 52 |
+
trust_remote_code=True
|
| 53 |
)
|
| 54 |
|
| 55 |
+
prompt=('One time they had a drumming contest, and I didn’t do very well: '
|
| 56 |
+
'They said my drumming was "too intellectual"; theirs was much more pulsing.')
|
| 57 |
+
output=pipeline(prompt, top_p=0.6, top_k=0, temperature=1, do_sample=True, use_cache=True, max_new_tokens=100)
|
| 58 |
print(output[0]["generated_text"])
|
| 59 |
```
|
| 60 |
|
|
|
|
| 68 |
)
|
| 69 |
tokenizer=AutoTokenizer.from_pretrained(pretrained_model_name_or_path="fromthesky/PLDR-LLM-v51-110M-4",
|
| 70 |
add_eos_token=False,
|
| 71 |
+
legacy=False,
|
| 72 |
trust_remote_code=True
|
| 73 |
)
|
| 74 |
+
|
| 75 |
+
prompt=('One time they had a drumming contest, and I didn’t do very well: '
|
| 76 |
+
'They said my drumming was "too intellectual"; theirs was much more pulsing.')
|
| 77 |
inputs = tokenizer([prompt], return_tensors="pt").to(device=device)
|
| 78 |
generated_ids = model.generate(**inputs,
|
| 79 |
+
max_new_tokens=100,
|
| 80 |
+
top_p=0.6,
|
| 81 |
+
top_k=0,
|
| 82 |
+
temperature=1,
|
| 83 |
+
do_sample=True,
|
| 84 |
+
use_cache=True
|
| 85 |
+
)
|
| 86 |
print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
|
| 87 |
```
|
| 88 |
+
<sup>\*</sup> `prompt` string is a quote from Richard Feynman in Surely You're Joking, Mr. Feynman! Adventures of a Curious Character.
|
| 89 |
|
| 90 |
#### PLDR-LLM specific configurations:
|
| 91 |
- `custom_G_type`: `None` for learned G values during pretraining, `'identity'` for LLM with SDPA equivalent, `'random'` for G values from a random normal distribution, `'external'` for custom G values that can be assigned after model initialization. This setting is more important for training purposes, for inference it is set in the model config.json file.
|
|
|
|
| 100 |
See config.json for other model configuration details.
|
| 101 |
|
| 102 |
#### Notes:
|
| 103 |
+
- This implementation of PLDR-LLM custom code was evaluated on Transformers 4.56.1 and pytorch 2.6.0.
|
| 104 |
+
- We also have a fork of transformers library with PLDR-LLM model support for future development. The PLDR-LLM model files are added to the library so custom model files are not necessary.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
```python
|
| 106 |
git clone https://github.com/burcgokden/transformers
|
| 107 |
cd transformers
|
config.json
CHANGED
|
@@ -34,7 +34,7 @@
|
|
| 34 |
"rope_theta": 10000.0,
|
| 35 |
"tie_word_embeddings": false,
|
| 36 |
"torch_dtype": "float32",
|
| 37 |
-
"transformers_version": "4.
|
| 38 |
"use_cache": true,
|
| 39 |
"vocab_size": 32000
|
| 40 |
}
|
|
|
|
| 34 |
"rope_theta": 10000.0,
|
| 35 |
"tie_word_embeddings": false,
|
| 36 |
"torch_dtype": "float32",
|
| 37 |
+
"transformers_version": "4.56.1",
|
| 38 |
"use_cache": true,
|
| 39 |
"vocab_size": 32000
|
| 40 |
}
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
transformers==4.
|
| 2 |
pytorch==2.6.0
|
| 3 |
sentencepiece==0.1.99
|
| 4 |
python==3.11
|
|
|
|
| 1 |
+
transformers==4.56.1
|
| 2 |
pytorch==2.6.0
|
| 3 |
sentencepiece==0.1.99
|
| 4 |
python==3.11
|