Instructions to use normalcomputing/extended-mind-llama-2-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use normalcomputing/extended-mind-llama-2-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="normalcomputing/extended-mind-llama-2-7b", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("normalcomputing/extended-mind-llama-2-7b", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use normalcomputing/extended-mind-llama-2-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "normalcomputing/extended-mind-llama-2-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "normalcomputing/extended-mind-llama-2-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/normalcomputing/extended-mind-llama-2-7b
- SGLang
How to use normalcomputing/extended-mind-llama-2-7b 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 "normalcomputing/extended-mind-llama-2-7b" \ --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": "normalcomputing/extended-mind-llama-2-7b", "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 "normalcomputing/extended-mind-llama-2-7b" \ --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": "normalcomputing/extended-mind-llama-2-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use normalcomputing/extended-mind-llama-2-7b with Docker Model Runner:
docker model run hf.co/normalcomputing/extended-mind-llama-2-7b
Upload 2 files
Browse files- modeling.py +4 -4
modeling.py
CHANGED
|
@@ -47,7 +47,7 @@ from transformers.utils import (
|
|
| 47 |
replace_return_docstrings,
|
| 48 |
)
|
| 49 |
|
| 50 |
-
from .configuration import ExtendedLlamaConfig
|
| 51 |
|
| 52 |
logger = logging.get_logger(__name__)
|
| 53 |
|
|
@@ -1144,7 +1144,7 @@ class ExtendedLlamaForCausalLM(LlamaPreTrainedModel):
|
|
| 1144 |
|
| 1145 |
_tied_weights_keys = ["lm_head.weight"]
|
| 1146 |
|
| 1147 |
-
def __init__(self, config, external_memories=None):
|
| 1148 |
super().__init__(config)
|
| 1149 |
self.model = ExtendedLlamaModel(config)
|
| 1150 |
self.vocab_size = config.vocab_size
|
|
@@ -1242,9 +1242,9 @@ class ExtendedLlamaForCausalLM(LlamaPreTrainedModel):
|
|
| 1242 |
if (
|
| 1243 |
self.memory_ids is not None and self.memories is None
|
| 1244 |
):
|
|
|
|
| 1245 |
self.memories = self.generate_cache(
|
| 1246 |
-
|
| 1247 |
-
cache_type=self.memory_type,
|
| 1248 |
)
|
| 1249 |
# EM: Remove special tokens from memory cache
|
| 1250 |
if self.remove_special_ids:
|
|
|
|
| 47 |
replace_return_docstrings,
|
| 48 |
)
|
| 49 |
|
| 50 |
+
from emts_clean.src.llama.configuration import ExtendedLlamaConfig
|
| 51 |
|
| 52 |
logger = logging.get_logger(__name__)
|
| 53 |
|
|
|
|
| 1144 |
|
| 1145 |
_tied_weights_keys = ["lm_head.weight"]
|
| 1146 |
|
| 1147 |
+
def __init__(self, config, external_memories:list=None):
|
| 1148 |
super().__init__(config)
|
| 1149 |
self.model = ExtendedLlamaModel(config)
|
| 1150 |
self.vocab_size = config.vocab_size
|
|
|
|
| 1242 |
if (
|
| 1243 |
self.memory_ids is not None and self.memories is None
|
| 1244 |
):
|
| 1245 |
+
self.memory_ids = torch.tensor([self.memory_ids], device=self.device) if type(self.memory_ids)==list else self.memory_ids
|
| 1246 |
self.memories = self.generate_cache(
|
| 1247 |
+
self.memory_ids, cache_type=self.memory_type,
|
|
|
|
| 1248 |
)
|
| 1249 |
# EM: Remove special tokens from memory cache
|
| 1250 |
if self.remove_special_ids:
|