初始化项目,由ModelHub XC社区提供模型

Model: jakiAJK/microsoft-phi-4_GPTQ-int4
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-08-06 12:17:18 +08:00
commit 8864c236eb
12 changed files with 602956 additions and 0 deletions

41
README.md Normal file
View File

@@ -0,0 +1,41 @@
---
library_name: transformers
base_model:
- microsoft/phi-4
---
### Requirements
```python
pip install -U transformers optimum auto-gptq
```
#### Transformers inference
```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16
device = "auto"
model_name = "jakiAJK/microsoft-phi-4_GPTQ-int4"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, device_map= device, trust_remote_code= True, torch_dtype= dtype)
model.eval()
chat = [
{ "role": "user", "content": "List any 5 country capitals." },
]
chat = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
input_tokens = tokenizer(chat, return_tensors="pt").to('cuda')
output = model.generate(**input_tokens,
max_new_tokens=100)
output = tokenizer.batch_decode(output)
print(output)
```