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

# office2md 2.0 重大更新

office2md 2.0 是一款强大的文档转换服务，专注于将各类办公文档转换为 Markdown 格式。 目标零成本实现高质量的数据抽取，为大模型RAG提供更准确的语料。

本次更新带来了多项重要功能增强。

## 主要特性

* 支持多种文件格式转换：PowerPoint、Word、Excel、图像、音频和 HTML
* 内置视觉理解和图片矫正模型
* 零成本实现高质量数据提取
* 支持并发处理，显著提升转换效率
* 集成 UVDoc 图像矫正技术

## 快速开始

使用 Docker 部署服务，支持CPU：

```bash theme={null}
docker run -p 8000:8000 registry.cn-hangzhou.aliyuncs.com/dockerhub_mirror/markitdown
```

## 性能优化

本次更新重构了处理逻辑，采用"切分-分批-解析-合并"的并行处理架构。性能测试显示，44页 PDF 的平均处理时间已优化至每页1秒以内。得益于并行处理架构，页数越多，性能优势越显著（考虑模型加载时间）。

<img src="https://minio.pigx.vip/oss/202501/1735878754.png" alt="1735878754" />

## 图像矫正能力

<img src="https://minio.pigx.vip/oss/202501/1735879095.png" alt="1735879095" />

集成了基于神经网格的 UVDoc 图形矫正工具，该工具源自 ETH Zurich 的研究成果。UVDoc 提供了一个仅 30MB 的轻量级模型，支持应用内嵌运行，在 CPU 环境下也能实现秒级的图片矫正。如果追求更高性能，office2md 同时支持 GPU 加速。此外，用户也可以选择使用 Gitee AI 提供的 UVDoc 在线服务。

<img src="https://minio.pigx.vip/oss/202501/1735878497.png" alt="1735878497" />

## 扩展：大模型结构化处理

office2md 支持通过大模型进行文档内容的结构化处理。以下是使用 Java 和 langchain4j SDK 的示例实现：

### 1. 定义 AI 助手接口

```java theme={null}
@AiService
public interface ProductInfoExtractor {
    @UserMessage("从 {{it}} 中提取详细的产品信息")
    ProductInfo extractProductInfo(String json);

    @Data
    class ProductInfo {
        @Description("产品名称")
        private String name;
        @Description("产品型号或规格")
        private String model;
        @Description("医疗器械注册证编号")
        private String registrationNumber;
        @Description("产品技术要求编号")
        private String technicalRequirementsNumber;
        @Description("生产许可证编号")
        private String productionLicenseNumber;
    }
}
```

### 2. 配置 AI 服务

```java theme={null}
@Bean
public ChatLanguageModel chatLanguageModel() {
    return OpenAiChatModel.builder()
            .apiKey(System.getenv("GITEE_AI_KEY"))
            .modelName("Qwen2-VL-72B")
            .logRequests(true)
            .baseUrl("https://ai.gitee.com/v1")
            .build();
}

@Bean
public ProductInfoExtractor personExtractor(ChatLanguageModel chatLanguageModel) {
    return AiServices.create(ProductInfoExtractor.class, chatLanguageModel);
}
```

通过以上配置，即可实现从自然语言文本到结构化 JSON 对象的转换。

* office2md 项目地址：[https://gitee.com/log4j/office2md](https://gitee.com/log4j/office2md)

* 如果您对 Java AI 应用开发感兴趣，可以学习一下笔者录制的这个系列视频：[Java AI应用开发](https://www.bilibili.com/video/BV1Yv21YzEP8)，当然是开源免费的啦。

* 当然如果对Java AI 开发感兴趣可以加入我们社群

<img src="https://minio.pigx.vip/oss/202501/1735880914.jpg" alt="1735880914" />
