Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 1383c76

Browse files
authored
[LLM Runtime]Add GGUF API UT (#1160)
1 parent ea58cd5 commit 1383c76

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

intel_extension_for_transformers/llm/runtime/graph/tests/test_llm_runtime.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@ def test_llm_runtime(self):
7676
print(config_type, cmpData(pt_logits.detach().numpy().flatten(), itrex_logits.flatten()))
7777

7878

79+
def test_gguf_api(self):
80+
model_name = "TheBloke/Mistral-7B-v0.1-GGUF"
81+
model_file = "mistral-7b-v0.1.Q4_0.gguf"
82+
tokenizer_name = "/tf_dataset2/models/pytorch/Mistral-7B-v0.1"
83+
84+
prompt = "Once upon a time"
85+
tokenizer = AutoTokenizer.from_pretrained(tokenizer_name, trust_remote_code=True)
86+
inputs = tokenizer(prompt, return_tensors="pt").input_ids
87+
streamer = TextStreamer(tokenizer)
88+
89+
model = AutoModelForCausalLM.from_pretrained(model_name, model_file = model_file)
90+
output = model.generate(inputs, streamer=streamer, max_new_tokens=10)
91+
print("output = ", output)
92+
assert(output == [[1, 5713, 3714, 264, 727, 28725, 736, 403, 264, 1628, 2746, 693, 6045, 298, 1220, 28723, 985]])
93+
94+
7995
def test_beam_search(self):
8096
model_name = "/tf_dataset2/models/pytorch/gpt-j-6B" # or local path to model
8197
prompts = [

0 commit comments

Comments
 (0)