--- title: "PASITA: plain text to Markdown" emoji: 📝 colorFrom: gray colorTo: red sdk: gradio sdk_version: 6.26.0 app_file: app.py short_description: Faithful text to Markdown with the 88M PASITA model python_version: "3.12" --- # PASITA: plain text to faithful Markdown Demo Space for [**OpceanAI/PASITA**](https://huggingface.co/OpceanAI/PASITA), an 88M-parameter decoder-only language model trained from scratch for one task: turning plain text into valid Markdown without inventing content. It adds structure, it does not rewrite the source. Paste OCR output, pasted HTML, meeting notes, a report or an article, and copy the result from the rendered view or download it as `pasita-*.md` from the source view. The Details tab of each run reports the route taken, numbers kept, content coverage and time. ## How this Space converts The app runs a small harness around the model instead of calling it once: 1. Free-form prose goes to PASITA. Three samples are generated with a fixed seed (`temperature 0.3`, adaptive length, adjustable 1-3 in Settings), each one is post-processed, and the reranker keeps the best candidate by number fidelity, content coverage, list and table preservation and GFM validity. 2. Inputs detected as HTML or as a delimited data dump are converted with a deterministic converter. The model does not handle raw markup or table synthesis at this size, and the demo does not pretend otherwise. 3. The status line under the header reports what actually happened for each run: which path ran, how many of the source numbers survived, content coverage and elapsed time. The same pipeline is available three ways: 1. **OpenAI-style REST API**: point any OpenAI SDK at `https://opceanai-pasita.hf.space/v1` (`/v1/chat/completions` with streaming, `/v1/convert`, `/v1/models`). Interactive docs at [`/docs`](https://opceanai-pasita.hf.space/docs). No API key required. ```python from openai import OpenAI client = OpenAI(base_url="https://opceanai-pasita.hf.space/v1", api_key="not-needed") resp = client.chat.completions.create( model="pasita-v1", messages=[{"role": "user", "content": ""}], ) print(resp.choices[0].message.content) ``` 2. **MCP server**: add `https://opceanai-pasita.hf.space/gradio_api/mcp/` to any MCP client. 3. **Gradio API**: the `convert` endpoint, documented in the `?view=api` drawer. Sampling temperature is fixed at 0.3 because that is the measured recipe; both REST endpoints accept an optional `max_tokens` cap. The Gradio v2 call endpoint also accepts the legacy `{"data": [...]}` body shape for compatibility. Errors use the OpenAI envelope (`{"error": {"message", "type", "param", "code"}}`); ZeroGPU quota exhaustion answers with HTTP 429. ## What works, what does not Valid regime: medium and long documents, in Spanish or English. The model is fragile on 1 to 3 line inputs, and it can truncate digits, drop secondary data or continue past completion. The harness cuts degenerate continuations and repair headings, but it cannot add information the model never generated. ## Model | | | |---|---| | Parameters | 88,099,584 (~88M) in bfloat16 | | Architecture | `LlamaForCausalLM`, 12 layers, hidden 768, GQA 12Q/4KV, ctx 2048 | | Tokenizer | custom 16k byte-level BPE | | Training | SFT + DPO + GRPO on markdown-derived ES/EN data | | License | Apache-2.0 | Benchmarks on the held-out PASITA-bench-1000, as reported on the model card: GFM validity 0.956, faithfulness 0.927, semantic faithfulness 0.888, table fidelity 1.000. ## Files - `app.py`: Gradio interface, ZeroGPU handlers and the OpenAI-style `/v1` API. - `pasita.py`: prompt, generation, post-processing, scoring and reranking harness. - `DESIGN.md`: visual direction, motion settings and the reason for each decision. - `DEPLOY.md`: step-by-step deployment guide for a local PC and for Hugging Face Spaces. ## Links - Model card: https://huggingface.co/OpceanAI/PASITA - API (OpenAI-style): https://opceanai-pasita.hf.space/v1 and docs at /docs - MCP: https://opceanai-pasita.hf.space/gradio_api/mcp/ - Gradio API: append `?view=api` to this Space URL.