-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_inference_simple.go
More file actions
50 lines (40 loc) · 989 Bytes
/
test_inference_simple.go
File metadata and controls
50 lines (40 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"context"
"fmt"
"os"
"path/filepath"
"github.com/xupit3r/vibrant/internal/inference"
"github.com/xupit3r/vibrant/internal/tensor"
)
func main() {
// Enable debug logging
inference.DebugInference = true
homeDir, _ := os.UserHomeDir()
modelPath := filepath.Join(homeDir, ".vibrant", "models", "qwen2.5-coder-3b-q4.gguf")
config := &inference.Config{
MaxTokens: 10,
Temperature: 0.0,
TopP: 1.0,
TopK: 0,
StopTokens: []int{},
Seed: 42,
Device: tensor.CPU, // Force CPU
}
fmt.Println("Loading model on CPU...")
engine, err := inference.NewEngine(modelPath, config)
if err != nil {
fmt.Printf("Failed: %v\n", err)
os.Exit(1)
}
prompt := "Hello world"
fmt.Printf("\nPrompt: %q\n\n", prompt)
ctx := context.Background()
opts := inference.GenerateOptions{MaxTokens: 10}
output, err := engine.Generate(ctx, prompt, opts)
if err != nil {
fmt.Printf("Generation failed: %v\n", err)
os.Exit(1)
}
fmt.Printf("\nFinal output: %q\n", output)
}