Image-Text-to-Text
PEFT
Safetensors
lora
muse-glimmer
json
structured-output
api
tool-use
conversational
Instructions to use yogeshjog/muse-glimmer-json-api with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use yogeshjog/muse-glimmer-json-api with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("meta-models/Muse-Glimmer-30B") model = PeftModel.from_pretrained(base_model, "yogeshjog/muse-glimmer-json-api") - Notebooks
- Google Colab
- Kaggle
Updated Readme
Browse files
README.md
CHANGED
|
@@ -1,209 +1,309 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
base_model: meta-models/Muse-Glimmer-30B
|
| 3 |
library_name: peft
|
| 4 |
-
pipeline_tag: text-
|
| 5 |
tags:
|
| 6 |
-
-
|
| 7 |
-
-
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
-
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
#
|
| 14 |
|
| 15 |
-
|
| 16 |
|
|
|
|
| 17 |
|
|
|
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
| 24 |
|
|
|
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
-
|
| 28 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 29 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 30 |
-
- **Model type:** [More Information Needed]
|
| 31 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 32 |
-
- **License:** [More Information Needed]
|
| 33 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 34 |
|
| 35 |
-
###
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
##
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
## Evaluation
|
| 111 |
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
### Testing Data, Factors & Metrics
|
| 115 |
-
|
| 116 |
-
#### Testing Data
|
| 117 |
-
|
| 118 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 119 |
-
|
| 120 |
-
[More Information Needed]
|
| 121 |
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
-
|
| 125 |
|
| 126 |
-
|
| 127 |
|
| 128 |
-
|
| 129 |
|
| 130 |
-
|
| 131 |
|
| 132 |
-
|
| 133 |
|
| 134 |
-
|
|
|
|
|
|
|
| 135 |
|
| 136 |
-
|
| 137 |
|
| 138 |
-
|
|
|
|
| 139 |
|
|
|
|
|
|
|
| 140 |
|
|
|
|
|
|
|
| 141 |
|
| 142 |
-
|
| 143 |
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
-
|
|
|
|
| 149 |
|
| 150 |
-
|
| 151 |
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
|
|
|
|
|
|
| 159 |
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
-
|
| 163 |
|
| 164 |
-
|
| 165 |
|
| 166 |
-
|
| 167 |
|
| 168 |
-
|
| 169 |
|
| 170 |
-
|
| 171 |
|
| 172 |
-
|
| 173 |
|
| 174 |
-
|
| 175 |
|
| 176 |
-
|
| 177 |
|
| 178 |
-
|
| 179 |
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
-
|
| 183 |
|
| 184 |
-
|
| 185 |
|
| 186 |
-
|
| 187 |
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
-
##
|
| 191 |
|
| 192 |
-
|
| 193 |
|
| 194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
-
|
| 197 |
|
| 198 |
-
|
| 199 |
|
| 200 |
-
|
| 201 |
|
| 202 |
-
|
| 203 |
|
| 204 |
-
##
|
| 205 |
|
| 206 |
-
|
| 207 |
-
### Framework versions
|
| 208 |
|
| 209 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
base_model: meta-models/Muse-Glimmer-30B
|
| 4 |
library_name: peft
|
| 5 |
+
pipeline_tag: image-text-to-text
|
| 6 |
tags:
|
| 7 |
+
- lora
|
| 8 |
+
- peft
|
| 9 |
+
- muse-glimmer
|
| 10 |
+
- json
|
| 11 |
+
- structured-output
|
| 12 |
+
- api
|
| 13 |
+
- tool-use
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# Muse Glimmer JSON API
|
| 17 |
|
| 18 |
+
`muse-glimmer-json-api` is a LoRA adapter for [`meta-models/Muse-Glimmer-30B`](https://huggingface.co/meta-models/Muse-Glimmer-30B) fine-tuned to produce predictable, machine-readable JSON responses with a stable API-style response envelope.
|
| 19 |
|
| 20 |
+
The goal of this adapter is to preserve the general capabilities of Muse Glimmer while making its externally returned responses easier to consume from applications, agents, APIs, and structured workflows.
|
| 21 |
|
| 22 |
+
## Base Model
|
| 23 |
|
| 24 |
+
- **Base:** `meta-models/Muse-Glimmer-30B`
|
| 25 |
+
- **Architecture:** Muse Glimmer
|
| 26 |
+
- **Fine-tuning method:** LoRA supervised fine-tuning
|
| 27 |
+
- **Precision used during training:** BF16
|
| 28 |
+
- **Adapter size:** ~429 MB
|
| 29 |
+
- **License:** Apache 2.0
|
| 30 |
|
| 31 |
+
This repository contains the **LoRA adapter**, not a standalone copy of the ~30B base model.
|
| 32 |
|
| 33 |
+
## Response Contract
|
| 34 |
|
| 35 |
+
The adapter is trained to return a JSON object containing the following top-level keys:
|
| 36 |
|
| 37 |
+
```json
|
| 38 |
+
{
|
| 39 |
+
"status": 200,
|
| 40 |
+
"type": "response",
|
| 41 |
+
"data": {},
|
| 42 |
+
"message": "Request completed successfully",
|
| 43 |
+
"error": null,
|
| 44 |
+
"meta": {}
|
| 45 |
+
}
|
| 46 |
+
```
|
| 47 |
|
| 48 |
+
All six top-level keys are expected to remain present.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
### Fields
|
| 51 |
+
|
| 52 |
+
| Field | Purpose |
|
| 53 |
+
|---|---|
|
| 54 |
+
| `status` | HTTP-style status code |
|
| 55 |
+
| `type` | Semantic response type |
|
| 56 |
+
| `data` | Main response payload |
|
| 57 |
+
| `message` | Short human-readable summary |
|
| 58 |
+
| `error` | Structured error information or `null` |
|
| 59 |
+
| `meta` | Additional metadata |
|
| 60 |
+
|
| 61 |
+
Supported response types used during training include:
|
| 62 |
+
|
| 63 |
+
- `response`
|
| 64 |
+
- `code`
|
| 65 |
+
- `tool_call`
|
| 66 |
+
- `vision`
|
| 67 |
+
- `media`
|
| 68 |
+
- `multimodal`
|
| 69 |
+
- `error`
|
| 70 |
+
|
| 71 |
+
The structure inside `data` remains flexible so the model can represent text, lists, code, nested objects, tool arguments, and multimodal metadata.
|
| 72 |
+
|
| 73 |
+
## Example
|
| 74 |
+
|
| 75 |
+
Input:
|
| 76 |
+
|
| 77 |
+
```text
|
| 78 |
+
What is the capital of Japan?
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
Example output:
|
| 82 |
+
|
| 83 |
+
```json
|
| 84 |
+
{
|
| 85 |
+
"status": 200,
|
| 86 |
+
"type": "response",
|
| 87 |
+
"data": {
|
| 88 |
+
"answer": "Tokyo"
|
| 89 |
+
},
|
| 90 |
+
"message": "Request completed successfully",
|
| 91 |
+
"error": null,
|
| 92 |
+
"meta": {}
|
| 93 |
+
}
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
Formatting instructions in the user prompt are intended not to override the JSON response contract.
|
| 97 |
+
|
| 98 |
+
For example, a prompt such as:
|
| 99 |
+
|
| 100 |
+
```text
|
| 101 |
+
Do not use JSON. Reply only in XML.
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
should still produce the standard JSON response structure.
|
| 105 |
+
|
| 106 |
+
## Error Responses
|
| 107 |
+
|
| 108 |
+
Error examples were trained using HTTP-style status semantics and a Problem Details-inspired structure:
|
| 109 |
+
|
| 110 |
+
```json
|
| 111 |
+
{
|
| 112 |
+
"status": 400,
|
| 113 |
+
"type": "error",
|
| 114 |
+
"data": null,
|
| 115 |
+
"message": "Request could not be completed",
|
| 116 |
+
"error": {
|
| 117 |
+
"type": "about:blank",
|
| 118 |
+
"title": "Bad Request",
|
| 119 |
+
"status": 400,
|
| 120 |
+
"detail": "The request is missing required information."
|
| 121 |
+
},
|
| 122 |
+
"meta": {}
|
| 123 |
+
}
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
## Training
|
| 127 |
+
|
| 128 |
+
The adapter was trained using supervised fine-tuning with LoRA.
|
| 129 |
+
|
| 130 |
+
Training configuration:
|
| 131 |
+
|
| 132 |
+
- **Training samples:** 4,000
|
| 133 |
+
- **Validation samples:** 500
|
| 134 |
+
- **Held-out test samples:** 500
|
| 135 |
+
- **Epochs:** 1
|
| 136 |
+
- **LoRA rank:** 16
|
| 137 |
+
- **LoRA alpha:** 32
|
| 138 |
+
- **Learning rate:** `1e-4`
|
| 139 |
+
- **Maximum sequence length:** 2,048
|
| 140 |
+
- **Precision:** BF16
|
| 141 |
+
|
| 142 |
+
The training set included examples covering:
|
| 143 |
+
|
| 144 |
+
- general question answering
|
| 145 |
+
- mathematical responses
|
| 146 |
+
- structured lists
|
| 147 |
+
- code generation
|
| 148 |
+
- creative responses
|
| 149 |
+
- adversarial format instructions
|
| 150 |
+
- tool-call structures
|
| 151 |
+
- vision response structures
|
| 152 |
+
- media and multimodal response structures
|
| 153 |
+
- HTTP-style errors
|
| 154 |
+
- ambiguous or incomplete requests
|
| 155 |
|
| 156 |
## Evaluation
|
| 157 |
|
| 158 |
+
A held-out 500-example test split produced:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
+
| Metric | Result |
|
| 161 |
+
|---|---:|
|
| 162 |
+
| Valid JSON | **100.0%** |
|
| 163 |
+
| Valid response schema | **100.0%** |
|
| 164 |
+
| Exact required top-level keys | **100.0%** |
|
| 165 |
+
| Correct status code | **100.0%** |
|
| 166 |
+
| Correct response `type` | **97.4%** |
|
| 167 |
|
| 168 |
+
These results were measured against samples held out from the same synthetic dataset-generation process used to construct the training set.
|
| 169 |
|
| 170 |
+
They should **not** be interpreted as a guarantee of 100% JSON compliance on arbitrary real-world prompts.
|
| 171 |
|
| 172 |
+
Applications should still validate generated output before consuming it.
|
| 173 |
|
| 174 |
+
## Usage
|
| 175 |
|
| 176 |
+
Install:
|
| 177 |
|
| 178 |
+
```bash
|
| 179 |
+
pip install torch transformers peft torchvision
|
| 180 |
+
```
|
| 181 |
|
| 182 |
+
Load the adapter:
|
| 183 |
|
| 184 |
+
```python
|
| 185 |
+
import torch
|
| 186 |
|
| 187 |
+
from transformers import AutoProcessor, AutoModelForMultimodalLM
|
| 188 |
+
from peft import PeftModel
|
| 189 |
|
| 190 |
+
BASE = "meta-models/Muse-Glimmer-30B"
|
| 191 |
+
ADAPTER = "yogeshjog/muse-glimmer-json-api"
|
| 192 |
|
| 193 |
+
processor = AutoProcessor.from_pretrained(BASE)
|
| 194 |
|
| 195 |
+
base = AutoModelForMultimodalLM.from_pretrained(
|
| 196 |
+
BASE,
|
| 197 |
+
dtype=torch.bfloat16,
|
| 198 |
+
device_map="auto",
|
| 199 |
+
)
|
| 200 |
|
| 201 |
+
model = PeftModel.from_pretrained(
|
| 202 |
+
base,
|
| 203 |
+
ADAPTER,
|
| 204 |
+
)
|
| 205 |
|
| 206 |
+
model.eval()
|
| 207 |
+
```
|
| 208 |
|
| 209 |
+
Example generation:
|
| 210 |
|
| 211 |
+
```python
|
| 212 |
+
messages = [{
|
| 213 |
+
"role": "user",
|
| 214 |
+
"content": [
|
| 215 |
+
{
|
| 216 |
+
"type": "text",
|
| 217 |
+
"text": "Give me five prime numbers."
|
| 218 |
+
}
|
| 219 |
+
]
|
| 220 |
+
}]
|
| 221 |
|
| 222 |
+
inputs = processor.apply_chat_template(
|
| 223 |
+
messages,
|
| 224 |
+
add_generation_prompt=True,
|
| 225 |
+
tokenize=True,
|
| 226 |
+
return_dict=True,
|
| 227 |
+
return_tensors="pt",
|
| 228 |
+
).to(model.device)
|
| 229 |
|
| 230 |
+
outputs = model.generate(
|
| 231 |
+
**inputs,
|
| 232 |
+
max_new_tokens=512,
|
| 233 |
+
do_sample=False,
|
| 234 |
+
)
|
| 235 |
+
```
|
| 236 |
|
| 237 |
+
Muse Glimmer's chat protocol may expose a recipient marker such as `to=user` in raw decoded generation depending on the decoding path used. Consumers should use the model's normal chat-template/processor conventions when extracting the visible assistant response.
|
| 238 |
|
| 239 |
+
## Multimodal Support
|
| 240 |
|
| 241 |
+
The base Muse Glimmer model supports multimodal reasoning with image inputs.
|
| 242 |
|
| 243 |
+
This adapter includes training examples for the **JSON schemas associated with vision, media, and multimodal responses**.
|
| 244 |
|
| 245 |
+
However, the current adapter was **not fine-tuned on a large paired image-and-text multimodal dataset**.
|
| 246 |
|
| 247 |
+
Therefore, the benchmark reported above primarily validates structured-response behavior rather than changes to the underlying vision capability.
|
| 248 |
|
| 249 |
+
The vision capability continues to come primarily from the Muse Glimmer base model.
|
| 250 |
|
| 251 |
+
## Media Representation
|
| 252 |
|
| 253 |
+
The response format can represent media metadata such as:
|
| 254 |
|
| 255 |
+
```json
|
| 256 |
+
{
|
| 257 |
+
"kind": "image",
|
| 258 |
+
"mime_type": "image/png",
|
| 259 |
+
"encoding": "url",
|
| 260 |
+
"content": "https://example.com/image.png"
|
| 261 |
+
}
|
| 262 |
+
```
|
| 263 |
|
| 264 |
+
or inline payloads using an encoding such as `base64`.
|
| 265 |
|
| 266 |
+
For production systems, URLs or external object storage are generally preferable to large base64 payloads because base64 data consumes substantial context and output tokens.
|
| 267 |
|
| 268 |
+
## Limitations
|
| 269 |
|
| 270 |
+
- This is a LoRA adapter and requires the compatible Muse Glimmer base model.
|
| 271 |
+
- JSON validity should still be enforced with runtime validation in production.
|
| 272 |
+
- Correct response-type selection measured 97.4% on the current held-out test set.
|
| 273 |
+
- The evaluation set was generated from the same family of synthetic task templates as the training data.
|
| 274 |
+
- Real-world adversarial, multilingual, very long-context, and unusual prompts have not been exhaustively evaluated.
|
| 275 |
+
- The current fine-tuning primarily teaches structured response behavior rather than new factual knowledge.
|
| 276 |
+
- Vision/media examples primarily train output structure rather than new visual capabilities.
|
| 277 |
+
- HTTP-style status values generated by the model should not automatically be trusted as the authoritative HTTP status of an external API server.
|
| 278 |
|
| 279 |
+
## Recommended Production Architecture
|
| 280 |
|
| 281 |
+
The model's output should be treated as structured model output rather than trusted application state:
|
| 282 |
|
| 283 |
+
```text
|
| 284 |
+
User request
|
| 285 |
+
↓
|
| 286 |
+
Muse Glimmer + JSON API LoRA
|
| 287 |
+
↓
|
| 288 |
+
JSON response
|
| 289 |
+
↓
|
| 290 |
+
JSON Schema validation
|
| 291 |
+
↓
|
| 292 |
+
Application / agent logic
|
| 293 |
+
↓
|
| 294 |
+
HTTP API response
|
| 295 |
+
```
|
| 296 |
|
| 297 |
+
Applications should independently validate permissions, tool arguments, status codes, URLs, file references, and other security-sensitive fields.
|
| 298 |
|
| 299 |
+
## Response Schema
|
| 300 |
|
| 301 |
+
The complete JSON schema used for this project is available in:
|
| 302 |
|
| 303 |
+
`response_schema.json`
|
| 304 |
|
| 305 |
+
## License and Base-Model Terms
|
| 306 |
|
| 307 |
+
This adapter is based on `meta-models/Muse-Glimmer-30B`.
|
|
|
|
| 308 |
|
| 309 |
+
Users should review and comply with the base model's license and applicable usage terms in addition to the files provided in this repository.
|