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ands for Single Training Sample
|
| 2 |
+
|
| 3 |
+
## Method 1: Using the Test Script (Easiest)
|
| 4 |
+
|
| 5 |
+
```bash
|
| 6 |
+
cd /workspace/ftt/codellama-migration
|
| 7 |
+
source /venv/main/bin/activate
|
| 8 |
+
python3 test_single_sample.py
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
This will:
|
| 12 |
+
- Load the first sample from `datasets/processed/split/train.jsonl`
|
| 13 |
+
- Show the instruction and expected response
|
| 14 |
+
- Load the fine-tuned model
|
| 15 |
+
- Generate and display the output
|
| 16 |
+
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
## Method 2: Direct Inference Command
|
| 20 |
+
|
| 21 |
+
### Test with a specific prompt from training data:
|
| 22 |
+
|
| 23 |
+
```bash
|
| 24 |
+
cd /workspace/ftt/codellama-migration
|
| 25 |
+
source /venv/main/bin/activate
|
| 26 |
+
|
| 27 |
+
python3 scripts/inference/inference_codellama.py \
|
| 28 |
+
--mode local \
|
| 29 |
+
--model-path training-outputs/codellama-fifo-v1 \
|
| 30 |
+
--base-model-path models/base-models/CodeLlama-7B-Instruct \
|
| 31 |
+
--prompt "You are Elinnos RTL Code Generator v1.0, a specialized Verilog/SystemVerilog code generation agent. Your role: Generate clean, synthesizable RTL code for hardware design tasks. Output ONLY functional RTL code with no \$display, assertions, comments, or debug statements.
|
| 32 |
+
|
| 33 |
+
Generate a synchronous FIFO with 8-bit data width, depth 4, write_enable, read_enable, full flag, empty flag, write_err flag (pulses if write when full), and read_err flag (pulses if read when empty)." \
|
| 34 |
+
--max-new-tokens 800 \
|
| 35 |
+
--temperature 0.3
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
---
|
| 39 |
+
|
| 40 |
+
## Method 3: Extract Sample and Test
|
| 41 |
+
|
| 42 |
+
### Extract a specific sample by line number:
|
| 43 |
+
|
| 44 |
+
```bash
|
| 45 |
+
cd /workspace/ftt/codellama-migration
|
| 46 |
+
source /venv/main/bin/activate
|
| 47 |
+
|
| 48 |
+
# Extract sample 1 (first line)
|
| 49 |
+
SAMPLE=$(sed -n '1p' datasets/processed/split/train.jsonl)
|
| 50 |
+
INSTRUCTION=$(echo $SAMPLE | python3 -c "import sys, json; print(json.load(sys.stdin)['instruction'])")
|
| 51 |
+
|
| 52 |
+
python3 scripts/inference/inference_codellama.py \
|
| 53 |
+
--mode local \
|
| 54 |
+
--model-path training-outputs/codellama-fifo-v1 \
|
| 55 |
+
--prompt "$INSTRUCTION" \
|
| 56 |
+
--max-new-tokens 800 \
|
| 57 |
+
--temperature 0.3
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
### Or use Python one-liner:
|
| 61 |
+
|
| 62 |
+
```bash
|
| 63 |
+
cd /workspace/ftt/codellama-migration
|
| 64 |
+
source /venv/main/bin/activate
|
| 65 |
+
|
| 66 |
+
python3 -c "
|
| 67 |
+
import json
|
| 68 |
+
from pathlib import Path
|
| 69 |
+
|
| 70 |
+
# Load first training sample
|
| 71 |
+
with open('datasets/processed/split/train.jsonl', 'r') as f:
|
| 72 |
+
sample = json.loads(f.readline())
|
| 73 |
+
instruction = sample['instruction']
|
| 74 |
+
print('Testing with instruction:')
|
| 75 |
+
print(instruction[:200] + '...')
|
| 76 |
+
print()
|
| 77 |
+
|
| 78 |
+
# Now run inference
|
| 79 |
+
import sys
|
| 80 |
+
sys.path.insert(0, 'scripts/inference')
|
| 81 |
+
from inference_codellama import load_local_model, generate_with_local_model
|
| 82 |
+
|
| 83 |
+
model, tokenizer = load_local_model(
|
| 84 |
+
'training-outputs/codellama-fifo-v1',
|
| 85 |
+
'models/base-models/CodeLlama-7B-Instruct'
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
response = generate_with_local_model(
|
| 89 |
+
model, tokenizer, instruction,
|
| 90 |
+
max_new_tokens=800, temperature=0.3, stream=False
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
print('=' * 80)
|
| 94 |
+
print('GENERATED OUTPUT:')
|
| 95 |
+
print('=' * 80)
|
| 96 |
+
print(response)
|
| 97 |
+
"
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
---
|
| 101 |
+
|
| 102 |
+
## Method 4: Interactive Mode
|
| 103 |
+
|
| 104 |
+
Test interactively with your own prompts:
|
| 105 |
+
|
| 106 |
+
```bash
|
| 107 |
+
cd /workspace/ftt/codellama-migration
|
| 108 |
+
source /venv/main/bin/activate
|
| 109 |
+
|
| 110 |
+
python3 scripts/inference/inference_codellama.py \
|
| 111 |
+
--mode local \
|
| 112 |
+
--model-path training-outputs/codellama-fifo-v1
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
Then type your prompt when prompted.
|
| 116 |
+
|
| 117 |
+
---
|
| 118 |
+
|
| 119 |
+
## Method 5: Test Specific Sample Number
|
| 120 |
+
|
| 121 |
+
To test sample N from training data:
|
| 122 |
+
|
| 123 |
+
```bash
|
| 124 |
+
cd /workspace/ftt/codellama-migration
|
| 125 |
+
source /venv/main/bin/activate
|
| 126 |
+
|
| 127 |
+
# Test sample 2 (change N=2 to any sample number)
|
| 128 |
+
N=2
|
| 129 |
+
INSTRUCTION=$(sed -n "${N}p" datasets/processed/split/train.jsonl | python3 -c "import sys, json; print(json.load(sys.stdin)['instruction'])")
|
| 130 |
+
|
| 131 |
+
python3 scripts/inference/inference_codellama.py \
|
| 132 |
+
--mode local \
|
| 133 |
+
--model-path training-outputs/codellama-fifo-v1 \
|
| 134 |
+
--prompt "$INSTRUCTION" \
|
| 135 |
+
--max-new-tokens 800 \
|
| 136 |
+
--temperature 0.3
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
---
|
| 140 |
+
|
| 141 |
+
## Quick Reference
|
| 142 |
+
|
| 143 |
+
**Model Path:** `training-outputs/codellama-fifo-v1`
|
| 144 |
+
**Base Model:** `models/base-models/CodeLlama-7B-Instruct`
|
| 145 |
+
**Training Data:** `datasets/processed/split/train.jsonl`
|
| 146 |
+
**Test Data:** `datasets/processed/split/test.jsonl`
|
| 147 |
+
|
| 148 |
+
**Recommended Parameters:**
|
| 149 |
+
- `--max-new-tokens 800` (for longer code)
|
| 150 |
+
- `--temperature 0.3` (deterministic code generation)
|
| 151 |
+
- `--temperature 0.1` (very deterministic, try if getting text instead of code)
|
| 152 |
+
|