## 1. Project Overview & Quickstart (mmulet/Contributing)

# Contributing

Open-source repository mmulet/Contributing

### Repository Details
- **Repository:** [mmulet/Contributing](https://github.com/mmulet/Contributing)
- **Primary Language:** Code

*Note: High-volume repository documentation is actively indexed and synchronized by YakaAI.*

## 2. Official Technical Reference & Guides (mmulet/docs)

## File: README.md

# docs

These are the docs for scaledown

---

## File: anatomy.mdx

# The Anatomy of an Effective AI Prompt

A well-structured prompt is the key to unlocking high-quality, relevant, and predictable responses from large language models. While a simple question can work, crafting a detailed prompt significantly improves performance by giving the model the necessary guardrails and information to succeed.

An effective prompt is a composite of several distinct elements that work together. Understanding these parts allows you to engineer your prompts for precision and control.

---
## Visualizing the Prompt Structure

These four components come together to form a complete, well-defined request. The following diagram illustrates how they are structured to build a final prompt.

```mermaid
graph TD
    A[Start] --> B{Prompt Assembly};

    subgraph "Prompt Components"
        C[Instruction]
        D[Context]
        E[Input Data]
        F[Output Indicator]
    end

    B --> G[Effective Prompt];

    C --> B;
    D --> B;
    E --> B;
    F --> B;

    G --> H{LLM};
    H --> I[High-Quality Response];

    style C fill:#c9f2c9,stroke:#333,stroke-width:2px
    style D fill:#f2d9c9,stroke:#333,stroke-width:2px
    style E fill:#c9d9f2,stroke:#333,stroke-width:2px
    style F fill:#f2c9f2,stroke:#333,stroke-width:2px
    style G fill:#f9f7ae,stroke:#333,stroke-width:2px
```

## The Four Core Components of a Prompt

A robust prompt can be broken down into four primary elements: Instruction, Context, Input Data, and Output Indicator. While not every prompt requires all four, combining them is the best way to ensure the model understands your exact needs.

### 1. Instruction
**What it is:** The `Instruction` is a clear, direct command that tells the model what task to perform. It's the primary verb of your request.

**Why it matters:** This is the most critical part of the prompt. An ambiguous or missing instruction forces the model to guess your intent, often leading to generic or incorrect responses.

**Examples:**
- "Summarize the following text."
- "Translate this sentence into French."
- "Write a Python function that calculates the factorial of a number."
- "Classify the sentiment of the user review below as positive, negative, or neutral."

### 2. Context
**What it is:** `Context` provides the model with external information, background, or constraints it should consider when performing the instruction. It sets the scene and provides necessary knowledge that the model might not have internally.

**Why it matters:** Context helps steer the model toward a more nuanced and accurate response. It reduces ambiguity and can prevent the model from making incorrect assumptions or "hallucinating" facts. For the ScaleDown API, the `context` field is where you would place this information for targeted compression.

**Examples:**
- "You are a helpful assistant for a financial services company. Your tone should be professional and encouraging." (Providing a persona)
- "The user is a beginner at programming, so explain the concepts simply." (Defining the audience)
- "Here is the article to be summarized: [long article text]..." (Supplying the source material)

### 3. Input Data
**What it is:** The `Input Data` is the specific piece of information that the model needs to act upon. It's the "subject" of your instruction's "verb."

**Why it matters:** This is the content you actually want the model to process. Without it, the instruction has nothing to work with. In the ScaleDown API, this corresponds to the `prompt` field.

**Examples:**
- "What is the capital of Nebraska?"
- `(Input for a function) n = 5`
- `(Text for translation) "Hello, how are you?"`

### 4. Output Indicator
**What it is:** The `Output Indicator` specifies the desired format, structure, or type of the response. It tells the model *how* to present its answer.

**Why it matters:** This component is crucial for programmatic use cases where a consistent output structure is required (e.g., JSON, Markdown, a simple list). It saves you post-processing steps and ensures the output is immediately usable.

**Examples:**
- "Provide the answer in JSON format with the keys 'capital' and 'state'."
- "Use bullet points for your summary."
- "Respond with only a single word."
- "Format the output as a Markdown table with two columns: 'Concept' and 'Explanation'."

---

---

## File: development.mdx

## Complete Workflow Example

Here's how to use the compressed context in your AI workflow:

<Tabs>
  <Tab title="Python" icon="python">
    ```python
    # Step 1: Compress your context with ScaleDown
    compressed_response = requests.post(
        "[https://api.scaledown.xyz/compress/raw/](https://api.scaledown.xyz/compress/raw/)",
        headers=headers,
        json={
            "context": "Long context about your topic...",
            "prompt": "What specific question you want answered",
            "model": "gpt-4o",
            "scaledown": {"rate": "auto"}
        }
    )

    compressed_context = compressed_response.json()["compressed_prompt"]

    # Step 2: Use compressed context with your AI provider
    your_actual_question = "What specific question you want answered"
    
    final_prompt = f"""
    System: You are a helpful assistant that answers questions using the provided context
    Context: {compressed_context}
    User: {your_actual_question}
    """

    # Step 3: Send to your AI provider (OpenAI, etc.)
    import openai
    ai_response = openai.ChatCompletion.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": final_prompt}]
    )
    ```
  </Tab>
</Tabs>

---

## Advanced Configuration Options

Once you're comfortable with basic compression, you can fine-tune your requests:

### Real Example

<Tabs>
  <Tab title="Python" icon="python">
    ```python
    # Example: Compress context about Messi
    payload = {
        "context": "Lionel Messi is an Argentine professional footballer who plays as a forward...",
        "prompt": "How many Ballon d'Or awards does Messi have?",
        "model": "gpt-4o",
        "scaledown": {
            "rate": "auto"
        }
    }

    # The response will contain compressed context that you can use
    # to build your final prompt for the AI model
    ```
  </Tab>
</Tabs>

---

## File: docs.json

{
  "name": "ScaleDown",
  "theme": "mint",
  "colors": {
    "primary": "#263AED",
    "light": "#263AED",
    "dark": "#117866"
  },
  "navigation": {
    "groups": [
      {
        "group": "Getting Started",
        "pages": [
          {
            "group": "Quick Start",
            "icon": "pen-paintbrush",
            "pages": [
              "quickstart",
              "workflow_example",
              "anatomy"
            ]
          },
          {
            "group": "Generic Prompt Reduction",
            "icon": "code-fork",
            "pages": [
              "generic-prompt-compression/overview",
              "generic-prompt-compression/hallucination-reductiono-pipeline"
            ]
          },
          {
            "group": "Prompt Compression for Reasoning Models",
            "icon": "code",
            "pages": [
              "code_compression/pareto_merging"
            ]
          }
        ]
      }
    ]
  }
}

---

## File: quickstart.mdx

# Getting Started with ScaleDown: Your AI Cost Optimization Guide

**ScaleDown Team** • March 13, 2025 • 10 min read

ScaleDown is a context engineering platform that intelligently compresses AI prompts while preserving semantic integrity and reducing hallucinations. Our research-backed compression algorithms analyze prompt components—from reasoning chains to code contexts—and apply targeted optimization techniques that maintain output quality while dramatically reducing token consumption.



### Our Technology Stack:
1. Reasoning Module Optimization: Dynamic model merging based on query difficulty
2. Code Context Compression: AST-based semantic filtering for programming tasks
3. Multimodal Audio Processing: Semantic tokenization for audio-visual applications
4. Benchmark-Driven Validation: Rigorous quality preservation across evaluation frameworks

---

## What is ScaleDown?

ScaleDown is an intelligent prompt compression service that reduces your AI token usage while preserving the semantic meaning of your prompts. Think of it as a smart compression tool for your AI conversations. You get the same quality responses while paying significantly less.

---

## Before You Start

To use ScaleDown, you'll need:
* An API key
* Basic knowledge of making API calls
* Your existing AI prompts that you want to optimize

Ready to get your API key? [Contact our sales team](https://blog.scaledown.ai/blog/getting-started).

---

## Your First ScaleDown Request

### Step 1: Set Up Your Request

Here's how to make your first API call to compress a prompt.

<Tabs>
  <Tab title="Python" icon="python">
    ```python
    import requests
    import json

    # ScaleDown API endpoint
    url = "[https://api.scaledown.xyz/compress/raw/](https://api.scaledown.xyz/compress/raw/)"

    # Your headers (replace YOUR_API_KEY with your actual key)
    headers = {
        'x-api-key': 'YOUR_API_KEY',
        'Content-Type': 'application/json'
    }
    ```
  </Tab>
  <Tab title="TypeScript" icon="typescript">
    ```typescript
    // ScaleDown API endpoint
    const url = "[https://api.scaledown.xyz/compress/raw/](https://api.scaledown.xyz/compress/raw/)";

    // Your headers (replace YOUR_API_KEY with your actual key)
    const headers = {
        'x-api-key': 'YOUR_API_KEY',
        'Content-Type': 'application/json'
    };
    ```
  </Tab>
  <Tab title="JavaScript" icon="javascript">
    ```javascript
    // ScaleDown API endpoint
    const url = "[https://api.scaledown.xyz/compress/raw/](https://api.scaledown.xyz/compress/raw/)";

    // Your headers (replace YOUR_API_KEY with your actual key)
    const headers = {
        'x-api-key': 'YOUR_API_KEY',
        'Content-Type': 'application/json'
    };
    ```
  </Tab>
</Tabs>

### Step 2: Configure Your Compression
Separate your context from your main prompt and set the compression rate to `"auto"` for the best results.

<Tabs>
  <Tab title="Python" icon="python">
    ```python
    payload = {
        "context": "Context about your specific topic or instructions here",
        "prompt": "Your actual query or question here",
        "model": "gpt-4o",
        "scaledown": {
            "rate": "auto" # Automatic compression rate optimization
        }
    }
    ```
  </Tab>
  <Tab title="TypeScript" icon="typescript">
    ```typescript
    interface CompressRequest {
        context: string;
        prompt: string;
        model: string;
        scaledown: {
            rate: string;
        };
    }

    const payload: CompressRequest = {
        context: "Context about your specific topic or instructions here",
        prompt: "Your actual query or question here",
        model: "gpt-4o",
        scaledown: {
            rate: "auto" // Automatic compression rate optimization
        }
    };
    ```
  </Tab>
  <Tab title="JavaScript" icon="javascript">
    ```javascript
    const payload = {
        context: "Context about your specific topic or instructions here",
        prompt: "Your actual query or question here",
        model: "gpt-4o",
        scaledown: {
            rate: "auto" // Automatic compression rate optimization
        }
    };
    ```
  </Tab>
</Tabs>

### Step 3: Make the Request
With your request set up and configured, you can now execute the API call.

<Tabs>
  <Tab title="Python" icon="python">
    ```python
    response = requests.post(url, headers=headers, data=json.dumps(payload))
    result = response.json()

    print(result)
    ```
  </Tab>
  <Tab title="TypeScript" icon="typescript">
    ```typescript
    // Assuming you're using a fetch-like library (e.g., node-fetch)
    const response = await fetch(url, {
        method: 'POST',
        headers: headers,
        body: JSON.stringify(payload)
    });
    const result = await response.json();

    console.log(result);
    ```
  </Tab>
  <Tab title="JavaScript" icon="javascript">
    ```javascript
    // Using Fetch API in a browser or Node.js environment
    fetch(url, {
        method: 'POST',
        headers: headers,
        body: JSON.stringify(payload)
    })
    .then(response => response.json())
    .then(result => {
        console.log(result);
    })
    .catch(error => console.error('Error:', error));
    ```
  </Tab>
</Tabs>

That's it! Your prompt is now compressed and ready to be used with your AI model.

---

## Understanding the Response Structure
The API response provides the compressed prompt along with useful metadata about the operation.
```json
{
  "compressed_prompt": "Your optimized context here...",
  "model_used": "gpt-4o",
  "original_prompt_tokens": 150,
  "compressed_prompt_tokens": 65,
  "successful": true,
  "latency_ms": 2341,
  "request_metadata": {
    "compression_time_ms": 2341,
    "compression_rate": "auto",
    "prompt_length": 425,
    "compressed_prompt_length": 189
  }
}
```

### Supported Models
The `model` parameter in your request payload specifies the target AI model. Here are the currently supported models:

**Gemini**
* `gemini-2.5-flash`
* `gemini-2.5-pro`
* `gemini-2.5-flash-lite`
* `gemini-2.0-flash`

**OpenAI**
* `gpt-4o`
* `gpt-4o-mini`

---

## File: web-editor.mdx

[Empty file]

---

## File: workflow_example.mdx

## Complete Workflow Example

Here's how to use the compressed context in your AI workflow:

<Tabs>
  <Tab title="Python" icon="python">
    ```python
    # Step 1: Compress your context with ScaleDown
    compressed_response = requests.post(
        "[https://api.scaledown.xyz/compress/raw/](https://api.scaledown.xyz/compress/raw/)",
        headers=headers,
        json={
            "context": "Long context about your topic...",
            "prompt": "What specific question you want answered",
            "model": "gpt-4o",
            "scaledown": {"rate": "auto"}
        }
    )

    compressed_context = compressed_response.json()["compressed_prompt"]

    # Step 2: Use compressed context with your AI provider
    your_actual_question = "What specific question you want answered"
    
    final_prompt = f"""
    System: You are a helpful assistant that answers questions using the provided context
    Context: {compressed_context}
    User: {your_actual_question}
    """

    # Step 3: Send to your AI provider (OpenAI, etc.)
    import openai
    ai_response = openai.ChatCompletion.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": final_prompt}]
    )
    ```
  </Tab>
</Tabs>

---

## Advanced Configuration Options

Once you're comfortable with basic compression, you can fine-tune your requests:

### Real Example

<Tabs>
  <Tab title="Python" icon="python">
    ```python
    # Example: Compress context about Messi
    payload = {
        "context": "Lionel Messi is an Argentine professional footballer who plays as a forward...",
        "prompt": "How many Ballon d'Or awards does Messi have?",
        "model": "gpt-4o",
        "scaledown": {
            "rate": "auto"
        }
    }

    # The response will contain compressed context that you can use
    # to build your final prompt for the AI model
    ```
  </Tab>
</Tabs>

---

## File: code_compression/pareto_merging.mdx

# Overview
#### Created as part of Eleuther SOAR by Nadya Devani, Pouya Sadeghi, Purva Kandalgaonkar, Suparnojit Sarkar

The **Pareto Merging method** is an advanced technique for combining multiple specialized AI models into a single, highly efficient model. Unlike traditional methods that create one static merged model, Pareto Merging produces a flexible framework that can generate an infinite number of model variations tailored to specific needs without retraining.

This method merges two types of models: a concise, non-reasoning Large Language Model (LLM) and a powerful Large Reasoning Model (LRM). The key innovation is a two-part architecture:
1.  **Preference-Independent Base Model**: A single, fixed base model combines the general knowledge of the LLM with the reasoning capabilities of the LRM.
2.  **Preference-Dependent Tensor**: A small, trainable "control knob" that is adjusted on-the-fly based on a predicted **question difficulty score**.

This allows the system to be dynamic: for easy questions, it leans towards the concise base model to save costs, and for difficult questions, it engages more reasoning power to ensure high accuracy.

### Architecture


## Pareto Merging API

### Overview
The ScaleDown Pareto Merging API provides dynamic, cost-effective reasoning. It merges a concise LLM with a powerful LRM, allowing you to balance response accuracy and token cost on a per-query basis. Instead of using a static model, our system adjusts its reasoning depth based on the predicted difficulty of your prompt, reducing costs by up to 30% while maintaining high accuracy.

---
### Quick Start
Get started in minutes by using our hosted API endpoint or by running the model locally with our Python package.

#### Installation
```bash
# Placeholder for package installation
pip install scaledown-paretomerge

---

## File: generic-prompt-compression/hallucination-reductiono-pipeline.mdx

## Work done by Yang Zhou

The pipeline's modular design can be integrated into ScaleDown as a new, premium API endpoint, `/pipeline/run`. This service would orchestrate complex LLM workflows while leveraging ScaleDown's core token compression at each step.

Here’s how the four key components can be integrated:

### 2.1. Composable Stages as a Service
The pipeline's core strength is its sequence of composable stages. This can be directly exposed to the user.

* **Integration:** The `/pipeline/run` endpoint would accept a JSON payload where the user defines the sequence of stages they want to run.
* **API Payload Example:**
    ```json
    {
      "question": "Who received the IEEE Frank Rosenblatt Award in 2010?",
      "models": {
        "target": "gemini-2.5-pro",
        "helper": "gemini-2.5-flash"
      },
      "pipeline": {
        "stages": [
          {"type": "baseline"},
          {"type": "apo"},
          {"type": "cove"}
        ]
      }
    }
    ```

### 2.2. "Gates" for Intelligent Cost Control
The pipeline uses "Gates" for early exits, saving cost and latency if a high-quality answer is found early.

* **Integration:** The gate policy can be a configurable parameter in the API call.
* **API Payload Example:**
    ```json
    {
      "question": "...",
      "pipeline": {
        "stages": [...],
        "gate": {
          "mode": "judge",
          "judge_model": "gemini-2.5-flash",
          "threshold": 0.9 
        }
      }
    }
    ```

### 2.3. Prompt Rewriting as a Pipeline Stage
The Automatic Prompt Optimization (`apo`) stage rewrites prompts for clarity.

* **Integration:** Offered as a specific stage (`"type": "apo"`). Users could call a pipeline with *only* the `apo` stage for advanced prompt engineering.

### 2.4. Verification and Self-Correction Stages
The Chain-of-Verification (`cove`) and `self_correct` stages fact-check and improve answers.

* **Integration:** Offered as optional, high-value stages. A user can add `"type": "cove"` to their pipeline to explicitly request that the model verifies its answer.

---

---

## File: generic-prompt-compression/overview.mdx

A brief summary of the pipeline: a multi-stage, configurable workflow designed to improve the factual accuracy and reduce hallucinations in LLM responses by applying techniques like prompt optimization, chain-of-verification, and confidence gatin

## Introduction
* Explain the problem: hallucinations and factual errors in LLMs.
* Position this pipeline as the next evolution of ScaleDown's mission—moving beyond optimizing the *input* (prompt) to orchestrating the entire *generation process*.

* ## Architectural Overview**
* This diagram illustrates the pipeline's flow, showing how a question passes through stages and gate checks, with the possibility of an early exit if an answer is deemed confident.

```mermaid
graph TD
    A[User Question] --> B[Stage 1: Baseline];
    B --> C{Gate Check};
    C --o|Confident? Yes| F[Final Answer];
    C --x|Confident? No| D[Stage 2: APO];
    D --> E{Gate Check};
    E --o|Confident? Yes| F;
    E --x|Confident? No| G[Stage 3: CoVe];
    G --> F;

    style F fill:#d4edda,stroke:#155724,stroke-width:2px
```
### **Model Roles**

The pipeline uses a multi-model architecture where different models act as specialized agents to improve efficiency and quality.

* **Target Model:** This is the primary, often most powerful, model responsible for generating the main answer to the user's question.
* **Helper Model:** A smaller, faster, and more cost-effective model used for auxiliary tasks like rewriting prompts (in the APO stage) or generating verification questions (in the CoVe stage).
* **Judge Model:** A model used exclusively by the `JudgeGate` to evaluate the confidence or correctness of an answer, deciding whether the pipeline can exit early or must proceed to the next stage.

---

### **4. Key Components of the Pipeline**

#### **4.1. Composable Stages**

A "stage" is a distinct, self-contained step in the pipeline that performs a specific operation on the user's question or a previous answer. The pipeline is built by chaining these stages together in a sequence.

* **Baseline:** The simplest stage. It directly asks the target model the initial question without any modification.
* **Automatic Prompt Optimization (APO):** This stage uses a helper model to rewrite the initial question into a more detailed and clearer prompt, which is then passed to the target model.
* **Chain-of-Verification (CoVe):** This stage improves the factual accuracy of an answer by having a helper model generate verification questions, answering them, and then producing a final, verified answer based on this new context.
* **Self-Correction:** An iterative stage where the target model is asked to critique and refine its own previous answer, improving its quality step-by-step.

#### **4.2. Intelligent Gating for Efficiency**

Gates are decision points between stages that determine whether the pipeline has produced a sufficiently high-quality answer to stop processing and return a result. Their main purpose is to save costs and reduce latency by avoiding unnecessary stages.

* **Oracle Gate:** A gate used for evaluation purposes only. It compares the model's answer to a known "ground truth" answer to check for correctness.
* **Judge Gate:** A gate designed for production use. It employs a separate "judge" LLM to programmatically assess the quality of the last answer and decide if it meets a predefined confidence threshold.

#### **4.3. Synergy with Token Compression**

The pipeline is designed to work seamlessly with ScaleDown's core compression technology. Each model role (`target`, `helper`, `judge`) can be individually wrapped with the `ScaleDownCompressionWrapper`. This means that every prompt generated at every stage is automatically compressed before being sent to an LLM, layering token savings on top of the workflow's logical efficiencies.

---

### **5. Example Workflow: A Question's Journey**

Let's trace a question through a `baseline -> apo -> cove` pipeline.

1.  **Initial State:**
    * **Question:** "What did the 2010 Frank Rosenblatt Award winner research?"
    * **Context (`ctx`):** `{'question': '...', 'last_answer': None}`

2.  **Stage 1: Baseline**
    * The `Baseline` stage sends the question directly to the **Target Model**.
    * **`ctx` is updated:** `{'last_answer': 'The winner researched neural networks.'}`

3.  **Gate Check (Not Confident)**
    * The `JudgeGate` determines the answer is too generic and lacks specifics. It decides to proceed.

4.  **Stage 2: Automatic Prompt Optimization (APO)**
    * The **Helper Model** rewrites the original question into: "Provide the specific research focus and key contributions of the person who won the IEEE Frank Rosenblatt Award in 2010."
    * This new, better prompt is sent to the **Target Model**.
    * **`ctx` is updated:** `{'last_answer': 'Geoffrey Hinton, winner of the 2010 award, researched deep learning and Boltzmann machines.'}`

5.  **Gate Check (Not Confident)**
    * The `JudgeGate` finds the answer better but wants factual verification. It decides to proceed.

6.  **Stage 3: Chain-of-Verification (CoVe)**
    * The **Helper Model** generates verification questions based on the last answer: `["Who won the 2010 Rosenblatt award?", "What are Boltzmann machines?"]`
    * The pipeline answers these questions.
    * The **Target Model** receives the original question plus the new verification context and produces a final, verified answer.
    * **`ctx` is updated:** `{'last_answer': 'The 2010 IEEE Frank Rosenblatt Award was given to Geoffrey Hinton for his foundational work on deep learning algorithms, specifically his co-invention of Boltzmann machines...'}`

7.  **Final Output:** The pipeline returns the final, verified `last_answer`.

---

### **6. Conclusion & Impact**

The Hallucination Reduction Pipeline provides a powerful, structured approach to enhancing LLM reliability.

* **Reduced Hallucinations:** Through explicit verification steps like CoVe, the model is forced to check its facts before finalizing an answer.
* **Higher Accuracy:** Iterative stages like APO and Self-Correction refine prompts and answers, leading to more precise and relevant results.
* **Cost Efficiency:** Intelligent gating prevents redundant processing, while integrated token compression lowers the cost of every LLM call.
* **Developer Control:** The modular, API-driven design allows developers to construct custom pipelines tailored to their specific needs for cost, speed, and accuracy.

---

## File: pictures/readme.md

add your images here

---

## File: writing-content/page.mdx

[Empty file]

---

## File: writing-content/text.mdx

[Empty file]