Text Generation
Transformers
PyTorch
code
gpt_bigcode
NarrowTransformer
Eval Results (legacy)
text-generation-inference
Instructions to use InfosysEnterprise/NT-Java-1.1B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use InfosysEnterprise/NT-Java-1.1B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="InfosysEnterprise/NT-Java-1.1B")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("InfosysEnterprise/NT-Java-1.1B") model = AutoModelForCausalLM.from_pretrained("InfosysEnterprise/NT-Java-1.1B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use InfosysEnterprise/NT-Java-1.1B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "InfosysEnterprise/NT-Java-1.1B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "InfosysEnterprise/NT-Java-1.1B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/InfosysEnterprise/NT-Java-1.1B
- SGLang
How to use InfosysEnterprise/NT-Java-1.1B 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 "InfosysEnterprise/NT-Java-1.1B" \ --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": "InfosysEnterprise/NT-Java-1.1B", "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 "InfosysEnterprise/NT-Java-1.1B" \ --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": "InfosysEnterprise/NT-Java-1.1B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use InfosysEnterprise/NT-Java-1.1B with Docker Model Runner:
docker model run hf.co/InfosysEnterprise/NT-Java-1.1B
updated quantization
Browse files
README.md
CHANGED
|
@@ -82,6 +82,24 @@ inputs = tokenizer.encode("public class HelloWorld {\n public static void mai
|
|
| 82 |
outputs = model.generate(inputs)
|
| 83 |
print(tokenizer.decode(outputs[0]))
|
| 84 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
### Attribution & Other Requirements
|
| 87 |
|
|
|
|
| 82 |
outputs = model.generate(inputs)
|
| 83 |
print(tokenizer.decode(outputs[0]))
|
| 84 |
```
|
| 85 |
+
#### Quantized Versions through `bitsandbytes`
|
| 86 |
+
* _Using 8-bit precision (int8)_
|
| 87 |
+
|
| 88 |
+
```java
|
| 89 |
+
# pip install bitsandbytes accelerate
|
| 90 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
| 91 |
+
|
| 92 |
+
# to use 4bit use `load_in_4bit=True` instead
|
| 93 |
+
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
| 94 |
+
|
| 95 |
+
checkpoint = "infosys/NT-Java-1.1B"
|
| 96 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 97 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config)
|
| 98 |
+
|
| 99 |
+
inputs = tokenizer.encode("public class HelloWorld {\n public static void main(String[] args) {", return_tensors="pt").to("cuda")
|
| 100 |
+
outputs = model.generate(inputs)
|
| 101 |
+
print(tokenizer.decode(outputs[0]))
|
| 102 |
+
```
|
| 103 |
|
| 104 |
### Attribution & Other Requirements
|
| 105 |
|