|
This version is still in development and is not considered stable yet. For the latest stable version, please use Spring AI 2.1.0! |
Quixotic AI Decision Models
jinfer is a pure-JVM inference engine from the Quixotic AI project. It runs GGUF decision models inside your application’s JVM, without an API key or external service, through the Decision Models API. A decision model picks one result from a known set of possible results, such as yes or no, one of a few categories, or a level on a scale, and tells you how likely each result is.
JinferDecisionModel answers all the questions of a call in one forward pass of the model, without generating text.
The jinfer Spring AI integration is an external module maintained by the Quixotic AI project, not part of the Spring AI repository.
Its artifacts are published to Maven Central under the com.qxotic group.
See the jinfer Spring AI README for the latest details.
|
Prerequisites
-
The same Java 25, JVM flags and Spring Boot requirements as Quixotic AI Chat.
-
A decision model family on the classpath:
Model
Input
Artifact
Text, images and video
jinfer-lfm3Text, images, video and audio
jinfer-lfm3vLLM Semantic Router d3 (edge, lite, nano and mini)
Text and images
jinfer-qwen35
Models are configured as a local .gguf path or as a model reference, such as LiquidAI/d1-2B-GGUF:Q8_0.
A model reference is downloaded when the application starts, or when you build the model yourself, and then cached.
No API key or external service is required.
Auto-configuration
Add the jinfer Spring Boot starter and a decision model family. Import both BOMs as shown in Quixotic AI Chat.
-
Maven
-
Gradle
<dependency>
<groupId>com.qxotic</groupId>
<artifactId>jinfer-spring-ai-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.qxotic</groupId>
<artifactId>jinfer-lfm3</artifactId>
</dependency>
dependencies {
implementation 'com.qxotic:jinfer-spring-ai-spring-boot-starter'
implementation 'com.qxotic:jinfer-lfm3'
}
Decision Properties
|
The To enable it, set To disable it, leave |
The prefix spring.ai.jinfer.decision is the property prefix to configure the jinfer decision model.
Property |
Description |
Default |
spring.ai.model.decision |
Enables the jinfer decision model. Set it to |
- |
spring.ai.jinfer.decision.model |
Required. A local GGUF path or a model reference for a decision model. |
- |
spring.ai.jinfer.decision.companions.media |
The model’s multimodal projector ( |
- |
spring.ai.jinfer.decision.context-capacity |
The upper bound of an input together with its questions, in tokens, where each row of media embeddings counts as one token. |
|
spring.ai.jinfer.decision.independent |
Answers each question of a call as if it were asked alone. See Several Questions in One Call. |
|
A configuration for Liquid AI’s d1, with its projector for image and video input, looks like this:
spring:
ai:
model:
decision: jinfer
jinfer:
decision:
model: LiquidAI/d1-2B-GGUF:Q8_0
companions:
media: LiquidAI/d1-2B-GGUF/mmproj-d1-2B-F16.gguf
The auto-configuration creates a JinferDecisionModel bean, unless the application defines its own DecisionModel bean.
Spring closes the bean at application shutdown, which releases the model weights.
To change how video frames are sampled, declare a VideoSampler bean.
Runtime Options
JinferDecisionModel has no options class.
The model, the context capacity and the independent setting are fixed when the model is built.
The portable DecisionOptions are accepted, but a model option that differs from the loaded model fails with an UnsupportedOperationException, because each JinferDecisionModel is bound to one GGUF file.
The name of the loaded model is its file name, such as d1-2B-Q8_0.gguf.
Several Questions in One Call
By default, the questions of a call are taken the way the model was trained to take several of them. d1 and d1-Omni read the input once for all the questions of a call, which is several times faster than one call per question. In exchange, the questions are not isolated from each other, so an answer can shift with the other questions of the call.
Set spring.ai.jinfer.decision.independent=true, or independent(true) on the builder, to answer each question as if it were asked alone.
d3 is not trained to read several questions together, so it answers each question alone either way.
Supported Features
| Feature | Supported | Notes |
|---|---|---|
Text input |
Yes |
|
Text with media |
Yes |
d1 reads images and video, d1-Omni also reads audio, and d3 reads images.
The |
Fields input |
Yes |
The fields are sent to the model as JSON, the form d1 was trained on, so use a |
Conversation input |
Yes |
The conversation is sent as a |
Probabilities |
Yes |
For all three kinds of questions. |
Confidence |
Yes |
For choice and score answers: the probability of the most likely option or level. |
Refusals |
No |
|
Response id |
No |
|
Model name |
Yes |
The file name of the loaded GGUF, or |
Token usage |
Yes |
The input tokens are the tokens that the call read, where each row of media embeddings counts as one token.
A decision generates no text, so the output tokens are |
A ChoiceAnswer selects the most likely option, and the first one listed when several are equally likely.
The getValue() of a ScoreAnswer is the expected level, the average level weighted by the probabilities.
For example, to ask about a photo that a customer sent with their message:
Media photo = new Media(MimeTypeUtils.IMAGE_JPEG, new FileSystemResource("parcel.jpg"));
DecisionResponse response = decisionModel.call(DecisionPrompt.builder()
.content(TextPart.of("The parcel arrived like this. Can I get a refund?"),
MediaPart.of(photo))
.question("damaged", YesNoQuestion.of("Is the parcel damaged?"))
.build());
Observability
Spring AI observes the calls as decision operations, with jinfer as the gen_ai.system key and the file name of the loaded GGUF as the gen_ai.request.model key.
The auto-configuration uses the application’s ObservationRegistry and an optional DecisionModelObservationConvention bean.
When you build the model yourself, pass them with observationRegistry(…) and observationConvention(…) on the builder.
See Decision Model observability.
Concurrency and Resources
A JinferDecisionModel processes one call at a time: concurrent calls wait in a fair queue.
For parallel calls, build several instances.
To share the weights between them, load the model once into an arena that your code manages with Models.loadDecisionModel(path, arena, companions), and build each instance with model(loaded).
Close the instances before you close the arena.
close() waits for the call in progress to finish, then frees the model state and the weights that the instance loaded.
Later calls fail with an IllegalStateException.
Sample Controller
The starter creates a DecisionModel bean that you can inject into your classes.
Here is a simple @RestController that uses it to sort customer messages:
@RestController
public class DecisionController {
private final DecisionModel decisionModel;
public DecisionController(DecisionModel decisionModel) {
this.decisionModel = decisionModel;
}
@GetMapping("/ai/decision")
public Map<String, Object> triage(@RequestParam(value = "message",
defaultValue = "Where is my order? I ordered it two weeks ago.") String message) {
DecisionResponse response = this.decisionModel.call(DecisionPrompt.builder()
.text(message)
.question("defect", YesNoQuestion.of("Does the customer report a defect?"))
.question("topic", ChoiceQuestion.of("What is the message about?",
"delivery", "product", "account", "other"))
.build());
return Map.of("defect", response.getYesNo("defect").isYes(),
"topic", response.getChoice("topic").getValue());
}
}
Manual Configuration
To use jinfer without Spring Boot auto-configuration, replace the starter with com.qxotic:jinfer-spring-ai and keep the BOMs and the model family:
-
Maven
-
Gradle
<dependency>
<groupId>com.qxotic</groupId>
<artifactId>jinfer-spring-ai</artifactId>
</dependency>
<dependency>
<groupId>com.qxotic</groupId>
<artifactId>jinfer-lfm3</artifactId>
</dependency>
dependencies {
implementation 'com.qxotic:jinfer-spring-ai'
implementation 'com.qxotic:jinfer-lfm3'
}
Then build the model:
try (var decisionModel = JinferDecisionModel.builder()
// or .modelPath(Path.of("d1-2B-Q8_0.gguf"))
.model("LiquidAI/d1-2B-GGUF:Q8_0")
// the projector, for images and video
.companion("media", "LiquidAI/d1-2B-GGUF/mmproj-d1-2B-F16.gguf")
.build()) {
DecisionResponse response = decisionModel.call(DecisionPrompt.builder()
.text("My new headphones arrived yesterday, but the left side doesn't work. Can I get my money back?")
.question("defect", YesNoQuestion.builder()
.text("Does the customer report a defect?")
.whenYes("Part of the item does not work as it should")
.whenNo("The item works, and the message is about something else")
.build())
.question("topic", ChoiceQuestion.builder()
.text("What is the message about?")
.option("delivery", "Where an order is, or when it will arrive")
.option("product", "A problem with an item the customer received")
.option("account", "Login, address or payment details")
.option("other", "None of the above")
.build())
.question("satisfaction", ScoreQuestion.of("How satisfied is the customer?", "unhappy", "neutral", "happy"))
.build());
boolean defect = response.getYesNo("defect").isYes();
String topic = response.getChoice("topic").getValue();
int satisfaction = response.getScore("satisfaction").getNearestLevel();
}
When you build the model yourself, your application owns it: use try-with-resources or close it at shutdown.
Configure local companion files with companionPath(capability, path).