File size: 2,216 Bytes
3a089e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# GPT4All-Model (Hanuman)

This folder contains the files needed to load and run the custom Hanuman model.

Included files:

- `pytorch_model.bin` — model weights
- `config.json` — model configuration
- `tokenizer.json`, `tokenizer_config.json`, `special_tokens_map.json` — tokenizer files
- `modeling.py` — custom `Hanuman` model implementation
- `hanuman_loader.py` — convenience loader (optional)

Quick usage (local files in this folder):

```python

# inference_local.py

from transformers import AutoTokenizer

from modeling import Hanuman

import torch



# load tokenizer from local folder

tokenizer = AutoTokenizer.from_pretrained('.')

# load model using the provided helper

model = Hanuman.from_pretrained('.', map_location='cpu')



prompt = "สวัสดีครับ ช่วยอธิบายสั้น ๆ เกี่ยวกับประเทศไทย"

inputs = tokenizer(prompt, return_tensors='pt')

outputs = model.generate(inputs['input_ids'], max_new_tokens=50, temperature=1.2, top_k=50, top_p=0.95)

print(tokenizer.decode(outputs[0], skip_special_tokens=True))

```

Or load from the Hugging Face Hub (if this folder was uploaded to the hub as the repo root):

```python

# inference_from_hub.py

from transformers import AutoTokenizer

from hanuman_loader import HanumanModel



repo_id = "ZombitX64/GPT4All-Model"

# tokenizer will download from HF

tokenizer = AutoTokenizer.from_pretrained(repo_id)

# HanumanModel downloads weights and modeling.py dynamically

model_wrapper = HanumanModel.from_pretrained(repo_id, map_location='cpu')

model = model_wrapper.model



prompt = "สวัสดีครับ ช่วยสรุปประเทศไทยสั้น ๆ"

inputs = tokenizer(prompt, return_tensors='pt')

outputs = model.generate(inputs['input_ids'], max_new_tokens=50)

print(tokenizer.decode(outputs[0], skip_special_tokens=True))

```

Notes:
- This repo uses a custom model class (`Hanuman`) — users must keep `modeling.py` or use the provided `hanuman_loader.py` that dynamically imports it.
- For CPU inference, install a CPU build of PyTorch. For GPU, install the appropriate CUDA-enabled PyTorch.