Instructions to use ufal/DAMA-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ufal/DAMA-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ufal/DAMA-7B")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ufal/DAMA-7B") model = AutoModelForCausalLM.from_pretrained("ufal/DAMA-7B") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ufal/DAMA-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ufal/DAMA-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ufal/DAMA-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ufal/DAMA-7B
- SGLang
How to use ufal/DAMA-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 "ufal/DAMA-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": "ufal/DAMA-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 "ufal/DAMA-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": "ufal/DAMA-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ufal/DAMA-7B with Docker Model Runner:
docker model run hf.co/ufal/DAMA-7B
Update README.md
Browse files
README.md
CHANGED
|
@@ -76,6 +76,28 @@ It results in balanced probabilities of gendered tokens in the model's output, a
|
|
| 76 |
The method for obtaining `P_c` is based on the Partial Least Square algorithm.
|
| 77 |
For more details, please refer to the [paper](https://openreview.net/pdf?id=XIZEFyVGC9).
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
## Evaluation
|
| 80 |
|
| 81 |
We evaluate the models on multiple benchmarks to assess gender bias and language understanding capabilities.
|
|
|
|
| 76 |
The method for obtaining `P_c` is based on the Partial Least Square algorithm.
|
| 77 |
For more details, please refer to the [paper](https://openreview.net/pdf?id=XIZEFyVGC9).
|
| 78 |
|
| 79 |
+
## Use
|
| 80 |
+
|
| 81 |
+
Following snippet shows the basic usage od DAMA for text generation.
|
| 82 |
+
|
| 83 |
+
```python
|
| 84 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 85 |
+
|
| 86 |
+
DAMA_SIZE= '7B'
|
| 87 |
+
OUTPUT_DIR = 'output'
|
| 88 |
+
model = AutoModelForCausalLM.from_pretrained(f"ufal/DAMA-{DAMA_SIZE}", offload_folder=OUTPUT_DIR,
|
| 89 |
+
torch_dtype=torch.float16, low_cpu_mem_usage=True,
|
| 90 |
+
device_map='auto')
|
| 91 |
+
|
| 92 |
+
tokenizer = AutoTokenizer.from_pretrained(f"ufal/DAMA-{DAMA_SIZE}", use_fast=True, return_token_type_ids=False)
|
| 93 |
+
|
| 94 |
+
prompt = "The lifeguard laughed because"
|
| 95 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 96 |
+
|
| 97 |
+
generate_ids = model.generate(inputs.input_ids, max_length=30)
|
| 98 |
+
tokenizer.batch_decode(generate_ids, skip_special_tokens=True)[0]
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
## Evaluation
|
| 102 |
|
| 103 |
We evaluate the models on multiple benchmarks to assess gender bias and language understanding capabilities.
|