Views
No views yet
| Property | Value |
|---|---|
| Base model | meta-llama/Llama-3.1-8B-Instruct |
| Fine-tuning method | LoRA (PEFT) |
| Quantization | 4-bit (NF4) |
| Trainable parameters | 41.9M / 8.07B (0.52%) |
| Training epochs | 3 |
| Final train loss | 1.07 → 0.52 |
| Final eval loss | 0.601 |
| Training time | ~30 minutes on RTX 5060 Ti |
ebool, euint8/16/32/64/128, eaddress@cofhe/sdk client library — encryption, decryption, permits1from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
2from peft import PeftModel
3import torch
4
5# Load base model in 4-bit
6bnb_config = BitsAndBytesConfig(
7 load_in_4bit=True,
8 bnb_4bit_quant_type="nf4",
9 bnb_4bit_compute_dtype=torch.float16,
10)
11base_model = AutoModelForCausalLM.from_pretrained(
12 "meta-llama/Llama-3.1-8B-Instruct",
13 quantization_config=bnb_config,
14 device_map="auto"
15)
16
17# Load LoRA adapter
18model = PeftModel.from_pretrained(base_model, "shree291/fhenix-llama3-lora")
19tokenizer = AutoTokenizer.from_pretrained("shree291/fhenix-llama3-lora")
20model.eval()
21
22# Ask a question
23messages = [
24 {"role": "system", "content": "You are an expert Fhenix blockchain developer assistant specializing in Fully Homomorphic Encryption (FHE) smart contracts."},
25 {"role": "user", "content": "How do I encrypt a uint32 value in a Solidity contract?"}
26]
27text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
28inputs = tokenizer(text, return_tensors="pt").to(model.device)
29
30with torch.no_grad():
31 outputs = model.generate(**inputs, max_new_tokens=300, temperature=0.7, do_sample=True)
32
33answer = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
34print(answer)FHE.select is a conditional operator that selects between two encrypted values based on an encrypted boolean condition — the FHE equivalent of an if-else statement. Use it when you need conditional logic without revealing the condition. Example:euint32 result = FHE.select(isGreater, a, b);
The Threshold Network provides decentralized threshold decryption. Multiple independent nodes collectively decrypt values using threshold cryptography — no single node can decrypt alone. It validates permits and ACL permissions before decrypting, secured via EigenLayer staking.
1{
2 "r": 16,
3 "lora_alpha": 32,
4 "target_modules": ["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
5 "lora_dropout": 0.05,
6 "bias": "none",
7 "task_type": "CAUSAL_LM"
8}