> ## Documentation Index
> Fetch the complete documentation index at: https://docs.somark.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Using SoMark in RAGFlow

> Add SoMark to the PDF knowledge base import flow through RAGFlow model provider and parsing settings

## Configuration flow

<Steps>
  <Step title="Confirm the Base URL">
    Confirm the SoMark API Base URL based on your deployment type.

    | Deployment          | Base URL                                 |
    | ------------------- | ---------------------------------------- |
    | Official SoMark API | `https://somark.cn/api/v1`               |
    | Self-hosted SoMark  | API Base URL of your self-hosted service |
  </Step>

  <Step title="Add the SoMark model provider">
    In RAGFlow, open user settings, go to the model provider settings page, select `SoMark` from the model provider list, and add a SoMark OCR model instance.

    <img src="https://mintcdn.com/soulcode-aa7e5a93/g3vkBK95Mv-OvA5f/images/SoMark_model_provider.webp?fit=max&auto=format&n=g3vkBK95Mv-OvA5f&q=85&s=9346a991510a8c632c8bd33a26d29065" alt="SoMark_model_provider" width="1600" height="782" data-path="images/SoMark_model_provider.webp" />
  </Step>

  <Step title="Fill in model settings">
    Fill in the following settings:

    | Field         | Required                  | Recommended value          | Description                                                   |
    | ------------- | ------------------------- | -------------------------- | ------------------------------------------------------------- |
    | Instance name | Yes                       | `somark`                   | Provider instance name in RAGFlow                             |
    | Model name    | Yes                       | `somark` or a custom name  | OCR model name used in parsing settings                       |
    | Base URL      | Yes                       | `https://somark.cn/api/v1` | SoMark API address                                            |
    | API Key       | Required for official API | `sk-...`                   | SoMark API Key; can be left empty for self-hosted deployments |

    <img src="https://mintcdn.com/soulcode-aa7e5a93/g3vkBK95Mv-OvA5f/images/Fill_in_model_settings.webp?fit=max&auto=format&n=g3vkBK95Mv-OvA5f&q=85&s=a798308299ae25d149c367fde7562a68" alt="Fill_in_model_settings" width="1600" height="778" data-path="images/Fill_in_model_settings.webp" />
  </Step>

  <Step title="Configure element output formats">
    Configure the return formats for images, formulas, tables, and chemical structures as needed.

    | Setting                   | Default | Options                     | Description                          |
    | ------------------------- | ------- | --------------------------- | ------------------------------------ |
    | Image format              | `url`   | `url`, `base64`, `none`     | How image elements are returned      |
    | Formula format            | `latex` | `latex`, `mathml`, `ascii`  | How formula elements are returned    |
    | Table format              | `html`  | `html`, `markdown`, `image` | How table elements are returned      |
    | Chemical structure format | `image` | `image`                     | How chemical structures are returned |

    <img src="https://mintcdn.com/soulcode-aa7e5a93/g3vkBK95Mv-OvA5f/images/Configure_element_output_formats.webp?fit=max&auto=format&n=g3vkBK95Mv-OvA5f&q=85&s=d31da3344a1196dd7d6254735fa8e9f4" alt="Configure_element_output_formats" width="1600" height="788" data-path="images/Configure_element_output_formats.webp" />
  </Step>

  <Step title="Configure parsing capability switches">
    Enable or disable parsing capabilities as needed.

    | Setting                  | Default | Description                                                                   |
    | ------------------------ | ------- | ----------------------------------------------------------------------------- |
    | Text cross-page merging  | Off     | Merge text that spans pages into continuous paragraphs                        |
    | Table cross-page merging | Off     | Merge tables that span pages into complete tables                             |
    | Title level recognition  | Off     | Recognize heading levels such as H1, H2, and H3                               |
    | Inline images            | Off     | Return images embedded in text paragraphs                                     |
    | Table images             | On      | Return images embedded in table cells                                         |
    | Image understanding      | On      | Perform semantic understanding and structured description for document images |
    | Keep headers and footers | Off     | Keep header and footer content when enabled                                   |

    <img src="https://mintcdn.com/soulcode-aa7e5a93/g3vkBK95Mv-OvA5f/images/Configure_parsing_capability_switches.webp?fit=max&auto=format&n=g3vkBK95Mv-OvA5f&q=85&s=5cae7781317608bb4d5baa26f76e3951" alt="Configure_parsing_capability_switches" width="1600" height="778" data-path="images/Configure_parsing_capability_switches.webp" />
  </Step>

  <Step title="Select SoMark in the knowledge base">
    Open the RAGFlow knowledge base where you want to import the PDF, upload the PDF file, open parsing settings, and set the PDF parsing method to `SoMark`.

    <img src="https://mintcdn.com/soulcode-aa7e5a93/g3vkBK95Mv-OvA5f/images/Select_SoMark_in_the_knowledge_base.webp?fit=max&auto=format&n=g3vkBK95Mv-OvA5f&q=85&s=804bb03f2156f1ddaffa425f370b6784" alt="Select_SoMark_in_the_knowledge_base" width="1600" height="781" data-path="images/Select_SoMark_in_the_knowledge_base.webp" />
  </Step>

  <Step title="Start parsing">
    Start the parsing task and wait for RAGFlow to complete the downstream ingestion flow. RAGFlow submits the PDF file to SoMark, polls the async parsing task, retrieves the structured JSON result, converts SoMark blocks to RAGFlow internal structures, and continues chunking, indexing, and vectorization.

    <img src="https://mintcdn.com/soulcode-aa7e5a93/g3vkBK95Mv-OvA5f/images/Start_parsing.webp?fit=max&auto=format&n=g3vkBK95Mv-OvA5f&q=85&s=4898b29b3905ad76e459eb62df53fa42" alt="Start_parsing" width="1600" height="777" data-path="images/Start_parsing.webp" />
  </Step>
</Steps>

***

## Parsing result mapping

Structured blocks returned by SoMark are mapped to RAGFlow internal layout types.

| SoMark type                    | RAGFlow type             | Description                                                            |
| ------------------------------ | ------------------------ | ---------------------------------------------------------------------- |
| `text`                         | `text`                   | Body text                                                              |
| `title`                        | `text`                   | Title text                                                             |
| `figure`                       | `image`                  | Image                                                                  |
| `figure_caption`               | `text`                   | Image caption                                                          |
| `table`                        | `table`                  | Table                                                                  |
| `table_caption`                | `text`                   | Table caption                                                          |
| `footnote`                     | `text`                   | Footnote                                                               |
| `sider`                        | `text`                   | Sidebar text                                                           |
| `code`                         | `code`                   | Code block                                                             |
| `choice`                       | `text`                   | Choice text                                                            |
| `reference`                    | `text`                   | Reference text                                                         |
| `equation`                     | `equation`               | Equation                                                               |
| `cs`                           | `image`                  | Chemical structure                                                     |
| `qrcode`                       | `image`                  | QR code                                                                |
| `stamp`                        | `image`                  | Stamp                                                                  |
| `header` / `footer`            | Depends on configuration | Discarded by default; kept when keeping headers and footers is enabled |
| `cate` / `cate_item` / `blank` | Discarded                | Table of contents noise or blank fields                                |

## Notes

* SoMark is currently mainly used for PDF parsing in RAGFlow.
* After document parsing succeeds, RAGFlow continues its existing knowledge base chunking, indexing, and vectorization flow.
* If a knowledge base uses SoMark for parsing, you still need to configure an embedding model normally. Otherwise, the downstream ingestion flow cannot complete.
