Quantization made by Richard Erkhov.
This model is randomly initialized, using the config from
mistralai/Mistral-7B-v0.1 but with smaller size.
1from optimum.intel.openvino import OVModelForCausalLM
2from transformers import pipeline
3from huggingface_hub import create_repo, upload_folder
4import torch
5import transformers
6import os
7
8model_id = 'mistralai/Mistral-7B-v0.1'
9save_path = '/tmp/yujiepan/mistral-tiny-random'
10repo_id = 'yujiepan/mistral-tiny-random'
11
12config = transformers.AutoConfig.from_pretrained(model_id)
13config.hidden_size = 8
14config.intermediate_size = 32
15config.num_attention_heads = 4
16config.num_hidden_layers = 2
17config.num_key_value_heads = 2
18print(config)
19
20tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
21tokenizer.save_pretrained(save_path)
22
23model = transformers.AutoModelForCausalLM.from_config(config, torch_dtype=torch.float16)
24model = model.half()
25
26pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, do_sample=False, device='cuda')
27print(pipe('Hello World!'))
28
29model.save_pretrained(save_path)
30
31ovmodel = OVModelForCausalLM.from_pretrained(save_path, export=True)
32ovmodel = ovmodel.half()
33ovmodel.save_pretrained(save_path)
34
35os.system(f'ls -alh {save_path}')
36create_repo(repo_id, exist_ok=True)
37upload_folder(repo_id=repo_id, folder_path=save_path)