Views
No views yet
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4tokenizer = AutoTokenizer.from_pretrained("lakkeo/stable-cypher-instruct-3b", trust_remote_code=True)
5model = AutoModelForCausalLM.from_pretrained("lakkeo/stable-cypher-instruct-3b", torch_dtype=torch.bfloat16, trust_remote_code=True)
6
7messages = [
8 {
9 "role": "user",
10 "content": "Show me the people who have Python and Cloud skills and have been in the company for at least 3 years."
11 }
12]
13
14prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
15
16inputs = tokenizer([prompt], return_tensors="pt").to(model.device)
17
18tokens = model.generate(
19 **inputs,
20 max_new_tokens=128,
21 do_sample=True,
22 top_p=0.9,
23 temperature=0.2,
24 pad_token_id=tokenizer.eos_token_id,
25 )
26
27outputs = tokenizer.batch_decode(tokens[:, inputs.input_ids.shape[-1]:], skip_special_tokens=False)[0]1from llama_cpp import Llama
2
3# Load the GGUF model
4print("Loading model...")
5model = Llama(
6 model_path=r"C:\Users\John\stable-cypher-instruct-3b.Q4_K_M.gguf",
7 n_ctx=512,
8 n_batch=512,
9 n_gpu_layers=-1, # Use all available GPU layers
10 max_tokens=128,
11 top_p=0.9,
12 temperature=0.2,
13 verbose=False
14)
15
16# Define your question
17question = "Show me the people who have Python and Cloud skills and have been in the company for at least 3 years."
18
19# Create the full prompt (simulating the apply_chat_template function)
20full_prompt = f"<|im_start|>system\nCreate a Cypher statement to answer the following question:<|im_end|>\n<|im_start|>user\n{question}<|im_end|>\n<|im_start|>assistant\n"
21
22# Generate response
23print("Generating response...")
24response = model(
25 full_prompt,
26 max_tokens=128,
27 stop=["<|im_end|>", "<|im_start|>"],
28 echo=False
29)
30
31# Extract and print the generated response
32answer = response['choices'][0]['text'].strip()
33print("\nQuestion:", question)
34print("\nGenerated Cypher statement:")
35print(answer)| Metric | stable-code-instruct-3b | gpt4-o | stable-cypher-instruct-3b |
|---|---|---|---|
| BLEU-4 | 19.07 | 32.35 | 88.63 |
| ROUGE-1 | 39.49 | 69.17 | 95.09 |
| ROUGE-2 | 24.82 | 46.97 | 90.71 |
| ROUGE-L | 29.63 | 65.24 | 91.51 |
| Jaro-Winkler | 52.21 | 86.38 | 95.69 |
| Jaccard | 25.55 | 72.80 | 90.78 |
| Pass@1 | 0.00 | 0.00 | 51.80 |


1{
2 "top.model_name": "Custom",
3 "top.finetuning_type": "lora",
4 "top.adapter_path": [],
5 "top.quantization_bit": "none",
6 "top.template": "default",
7 "top.rope_scaling": "none",
8 "top.booster": "none",
9 "train.training_stage": "Supervised Fine-Tuning",
10 "train.dataset_dir": "data",
11 "train.dataset": [
12 "cypher_opus"
13 ],
14 "train.learning_rate": "2e-4",
15 "train.num_train_epochs": "5.0",
16 "train.max_grad_norm": "1.0",
17 "train.max_samples": "5000",
18 "train.compute_type": "fp16",
19 "train.cutoff_len": 256,
20 "train.batch_size": 16,
21 "train.gradient_accumulation_steps": 2,
22 "train.val_size": 0.1,
23 "train.lr_scheduler_type": "cosine",
24 "train.logging_steps": 10,
25 "train.save_steps": 100,
26 "train.warmup_steps": 20,
27 "train.neftune_alpha": 0,
28 "train.optim": "adamw_torch",
29 "train.resize_vocab": false,
30 "train.packing": false,
31 "train.upcast_layernorm": false,
32 "train.use_llama_pro": false,
33 "train.shift_attn": false,
34 "train.report_to": false,
35 "train.num_layer_trainable": 3,
36 "train.name_module_trainable": "all",
37 "train.lora_rank": 64,
38 "train.lora_alpha": 64,
39 "train.lora_dropout": 0.1,
40 "train.loraplus_lr_ratio": 0,
41 "train.create_new_adapter": false,
42 "train.use_rslora": false,
43 "train.use_dora": true,
44 "train.lora_target": "",
45 "train.additional_target": "",
46 "train.dpo_beta": 0.1,
47 "train.dpo_ftx": 0,
48 "train.orpo_beta": 0.1,
49 "train.reward_model": null,
50 "train.use_galore": false,
51 "train.galore_rank": 16,
52 "train.galore_update_interval": 200,
53 "train.galore_scale": 0.25,
54 "train.galore_target": "all"
55}