• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rendezqueue / rendezllama / 21148372818

19 Jan 2026 06:47PM UTC coverage: 90.744% (-0.2%) from 90.909%
21148372818

push

github

grencez
feat(option): to use greedy sampling

14 of 19 new or added lines in 3 files covered. (73.68%)

2049 of 2258 relevant lines covered (90.74%)

117.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.99
/test/language/inference_test.cc
1
#include "src/chat/display.hh"
2
#include "src/chat/opt.hh"
3
#include "src/chat/trajectory.hh"
4
#include "src/language/inference.hh"
5
#include "src/language/vocabulary.hh"
6

7
#include <cassert>
8
#include <iostream>
9
#include <tuple>
10
#include <vector>
11

12
#include <fildesh/fildesh.h>
13

14
#include "llama.h"
15

16
using rendezllama::ChatDisplay;
17
using rendezllama::ChatOptions;
18
using rendezllama::ChatTrajectory;
19
using rendezllama::Inference;
20
using rendezllama::Vocabulary;
21

22
static
23
  void
24
noop_log_callback(enum ggml_log_level level, const char* text, void* user_data)
174✔
25
{
26
  (void) level;
174✔
27
  (void) text;
174✔
28
  (void) user_data;
174✔
29
}
174✔
30

31
static void test_antiprompt_suffix() {
1✔
32
  std::set<std::string> antiprompts;
1✔
33
  antiprompts.insert("User:");
2✔
34
  antiprompts.insert("\nUser:");
2✔
35

36
  // Case: No match
37
  assert(rendezllama::antiprompt_suffix("Hello World", antiprompts).empty());
1✔
38

39
  // Case: Exact match
40
  assert(rendezllama::antiprompt_suffix("User:", antiprompts) == "User:");
1✔
41

42
  // Case: Suffix match
43
  assert(rendezllama::antiprompt_suffix("Hello User:", antiprompts) == "User:");
1✔
44

45
  // Case: Longest match check
46
  assert(rendezllama::antiprompt_suffix("Hello\nUser:", antiprompts) == "\nUser:");
1✔
47

48
  // Case: Partial match should fail
49
  assert(rendezllama::antiprompt_suffix("User", antiprompts).empty());
1✔
50
}
1✔
51

52
static void inference_test(const std::string& model_filename) {
1✔
53
  llama_log_set(noop_log_callback, NULL);
1✔
54

55
  ChatOptions opt;
1✔
56
  opt.model_filename = model_filename;
1✔
57
  // Initialize infer_via with default Sampling to avoid assertion failure in Inference::reinitialize.
58
  opt.infer_via.emplace<rendezllama::inference::Sampling>();
1✔
59

60
  struct llama_model* model = nullptr;
1✔
61
  struct llama_context* ctx = nullptr;
1✔
62
  std::tie(model, ctx) = rendezllama::make_llama_context(opt);
1✔
63
  assert(model);
1✔
64
  assert(ctx);
1✔
65

66
  Vocabulary vocabulary(model);
1✔
67
  Inference inference(vocabulary);
1✔
68
  ChatTrajectory chat_traj(vocabulary.bos_token_id());
1✔
69
  ChatDisplay chat_disp;
1✔
70
  // Use /dev/null for display to avoid spamming test output, we check tokens programmatically.
71
  chat_disp.out_ = open_FildeshOF("/dev/null");
1✔
72

73
  // Add a simple prompt to start generation.
74
  chat_traj.tokenize_append("Once upon a time", vocabulary);
1✔
75
  chat_disp.show_new(chat_traj, vocabulary);
1✔
76

77
  using rendezllama::inference::AdjustViaKind;
1✔
78
  using rendezllama::inference::Sampling;
1✔
79

80
  std::vector<Sampling> samplings;
1✔
81
  // Temperature
82
  {
1✔
83
    Sampling s;
1✔
84
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::temperature>, 0.8f);
1✔
85
    samplings.push_back(s);
1✔
86
  }
×
87
  // Top K
88
  {
1✔
89
    Sampling s;
1✔
90
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::top_k>, 40u);
1✔
91
    samplings.push_back(s);
1✔
92
  }
×
93
  // Top P
94
  {
1✔
95
    Sampling s;
1✔
96
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::top_p>, 0.9f);
1✔
97
    samplings.push_back(s);
1✔
98
  }
×
99
  // Min P
100
  {
1✔
101
    Sampling s;
1✔
102
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::min_p>, 0.05f);
1✔
103
    samplings.push_back(s);
1✔
104
  }
×
105
   // Typical P
106
  {
1✔
107
    Sampling s;
1✔
108
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::typical_p>, 0.9f);
1✔
109
    samplings.push_back(s);
1✔
110
  }
×
111
  // Greedy
112
  {
1✔
113
    Sampling s;
1✔
114
    s.pick_via = rendezllama::inference::Determinism{};
1✔
115
    samplings.push_back(s);
1✔
NEW
116
  }
×
117
  // Mirostat V2
118
  {
1✔
119
    Sampling s;
1✔
120
    s.pick_via = rendezllama::inference::Mirostat{2, 5.0f, 0.1f};
1✔
121
    samplings.push_back(s);
1✔
122
  }
×
123
  // Penalties
124
  {
1✔
125
    Sampling s;
1✔
126
    rendezllama::inference::PenalizeWith p;
1✔
127
    p.window_length = 5;
1✔
128
    p.repetition = 1.1f;
1✔
129
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::penalize_with>, p);
1✔
130
    samplings.push_back(s);
1✔
131
  }
×
132
  // Dry
133
  {
1✔
134
    Sampling s;
1✔
135
    rendezllama::inference::Dry d;
1✔
136
    d.multiplier = 0.8f;
1✔
137
    d.base = 1.75f;
1✔
138
    d.allowed_length = 2;
1✔
139
    d.window_length = 0; // Default.
1✔
140
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::dry>, d);
1✔
141
    samplings.push_back(s);
1✔
142
  }
×
143
  // XTC
144
  {
1✔
145
    Sampling s;
1✔
146
    rendezllama::inference::Xtc x;
1✔
147
    x.threshold = 0.1f;
1✔
148
    x.probability = 0.5f;
1✔
149
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::xtc>, x);
1✔
150
    samplings.push_back(s);
1✔
151
  }
×
152

153
  // Iterate through different sampling options.
154
  for (const auto& sampling : samplings) {
11✔
155
    opt.infer_via = sampling;
10✔
156
    if (!inference.commit_to_context(ctx, chat_disp, chat_traj, opt, model)) {
10✔
157
      break;
158
    }
159
    inference.sample_to_trajectory(chat_traj, ctx, false);
10✔
160
    chat_disp.show_new(chat_traj, vocabulary);
10✔
161
  }
162

163
  llama_free(ctx);
1✔
164
  llama_model_free(model);
1✔
165
}
1✔
166

167
int main(int argc, char** argv)
1✔
168
{
169
  rendezllama::GlobalScope rendezllama_global_scope;
1✔
170
  assert(argc == 2);
1✔
171
  test_antiprompt_suffix();
1✔
172
  inference_test(argv[1]);
2✔
173
  return 0;
1✔
174
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc