Files
lemonade/test/cpp/test_flm_model_labels.cpp
Satya Devineni 11a3ea0ac5 feat(backend): FLM 1.0.11 decision models support (#4037)
* main into zero shot, post refactoring

* cleanup

* cleanup

* CR feedback: fixed the residency document clarification bug

* cr feedback: fake tests with propoer assertions

* stacks on the zero shot work in 3952

* pr feedback: better policy checks and logging for backend failures

* pr feedback: adding on_truncation

* pr feedback: adding the truncation support for classifier and fixing documentation issues

* CI fix and doc enhancement

* pr feedback: fixed edge cases

* added check for 0.3.7 truncated verification

* pr feedback: router validation and argument handling

* Added the example lfm2 ONNX model

* pr feedback: added max-length and 3 flag truncate flags

* pin bump to 0.4.0 and more tests for zero-shot

* CI fix

* pr feedback: model level filtering

* PR Feedback: CR feedback

* restricting decision models based on model family. 8k context limit by default for encoder decision models

* checks at router level to reject wrongly labeled systemone models with 400

* systemone support through FLM 1.0.11

* added truncation FLM check

* pr feedback: truncated is set to false and better error handling with input lengths

* pr feedback: default set to 4k, limits passed down by llama-server, truncated  is added to systemone

* truncated documentation

* pr feedback: checks the token count instead of the template

* missing tests

* CI bugs
2026-11-05 00:01:33 +00:00

62 lines
2.0 KiB
C++

#include "lemon/backends/fastflowlm/flm_model_labels.h"
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using lemon::backends::fastflowlm::add_flm_mode_labels;
namespace {
int failures = 0;
void expect(bool condition, const std::string& message) {
if (condition) {
std::cout << "ok: " << message << std::endl;
return;
}
std::cerr << "FAIL: " << message << std::endl;
++failures;
}
bool has(const std::vector<std::string>& labels, const std::string& label) {
return std::find(labels.begin(), labels.end(), label) != labels.end();
}
std::vector<std::string> labelled(const std::string& checkpoint,
std::vector<std::string> labels) {
add_flm_mode_labels(checkpoint, labels);
return labels;
}
} // namespace
int main() {
const auto d3 = labelled("d3:lite", {"decision"});
expect(has(d3, "classification") && has(d3, "systemone"),
"a decision model deploys as a SystemOne classifier");
expect(!has(d3, "chat"), "a decision model is not a chat model");
expect(has(d3, "decision"), "FLM's own labels are kept");
expect(labelled("whisper-v3:turbo", {}) == std::vector<std::string>{"transcription"},
"whisper is a transcription model");
expect(labelled("embed-gemma:300m", {}) == std::vector<std::string>{"embeddings"},
"embed-gemma is an embedding model");
expect(labelled("EMBED-Gemma:300m", {}) == std::vector<std::string>{"embeddings"},
"the checkpoint name is matched without case");
const auto chat = labelled("qwen3.5:4b", {"reasoning", "vision"});
expect(has(chat, "chat") && !has(chat, "classification"),
"any other model is a chat model");
expect(labelled("llama3.2:1b", {"chat"}) == std::vector<std::string>{"chat"},
"a chat label is not added twice");
if (failures != 0) {
std::cerr << failures << " check(s) failed" << std::endl;
return 1;
}
std::cout << "all checks passed" << std::endl;
return 0;
}