Text Generation
Transformers
Safetensors
Undetermined
indus-script
ancient-scripts
archaeology
nlp
sequence-modeling
grammar-analysis
undeciphered-script
Instructions to use hellosindh/indus-script-models with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hellosindh/indus-script-models with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hellosindh/indus-script-models")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("hellosindh/indus-script-models", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use hellosindh/indus-script-models with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hellosindh/indus-script-models" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hellosindh/indus-script-models", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/hellosindh/indus-script-models
- SGLang
How to use hellosindh/indus-script-models 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 "hellosindh/indus-script-models" \ --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": "hellosindh/indus-script-models", "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 "hellosindh/indus-script-models" \ --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": "hellosindh/indus-script-models", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use hellosindh/indus-script-models with Docker Model Runner:
docker model run hf.co/hellosindh/indus-script-models
Update inference.py
Browse files- inference.py +3 -3
inference.py
CHANGED
|
@@ -80,13 +80,13 @@ def load_tokenizer(data_dir):
|
|
| 80 |
def load_bert_mlm(model_dir):
|
| 81 |
from transformers import BertForMaskedLM
|
| 82 |
return BertForMaskedLM.from_pretrained(
|
| 83 |
-
str(model_dir / "mlm"
|
| 84 |
|
| 85 |
|
| 86 |
def load_bert_cls(model_dir):
|
| 87 |
from transformers import BertForSequenceClassification
|
| 88 |
return BertForSequenceClassification.from_pretrained(
|
| 89 |
-
str(model_dir / "cls"
|
| 90 |
|
| 91 |
|
| 92 |
def load_ngram(model_dir):
|
|
@@ -112,7 +112,7 @@ def load_electra(model_dir):
|
|
| 112 |
attention_mask=attention_mask)
|
| 113 |
return self.classifier(self.dropout(out.last_hidden_state))
|
| 114 |
|
| 115 |
-
p = model_dir / "electra"
|
| 116 |
with open(p / "discriminator_config.json") as f:
|
| 117 |
cfg = json.load(f)
|
| 118 |
m = ElectraDisc(BertConfig(**cfg))
|
|
|
|
| 80 |
def load_bert_mlm(model_dir):
|
| 81 |
from transformers import BertForMaskedLM
|
| 82 |
return BertForMaskedLM.from_pretrained(
|
| 83 |
+
str(model_dir / "mlm")).to(device).eval()
|
| 84 |
|
| 85 |
|
| 86 |
def load_bert_cls(model_dir):
|
| 87 |
from transformers import BertForSequenceClassification
|
| 88 |
return BertForSequenceClassification.from_pretrained(
|
| 89 |
+
str(model_dir / "cls")).to(device).eval()
|
| 90 |
|
| 91 |
|
| 92 |
def load_ngram(model_dir):
|
|
|
|
| 112 |
attention_mask=attention_mask)
|
| 113 |
return self.classifier(self.dropout(out.last_hidden_state))
|
| 114 |
|
| 115 |
+
p = model_dir / "electra"
|
| 116 |
with open(p / "discriminator_config.json") as f:
|
| 117 |
cfg = json.load(f)
|
| 118 |
m = ElectraDisc(BertConfig(**cfg))
|