---
title: ofa_sudoku_kaggle_large
canonical_url: "https://www.modelscope.cn/models/damo/ofa_sudoku_kaggle_large"
md_url: "https://www.modelscope.cn/models/damo/ofa_sudoku_kaggle_large.md"
repository: damo/ofa_sudoku_kaggle_large
chinese_name: "OFA数独解决方案-large"
last_updated: 2025-06-11
license: "Apache License 2.0"
model_type:
  - ofa
architectures:
  - OFAModel
library_name:
  - pytorch
frameworks:
  - pytorch
domain:
  - multi-modal
downloads: 169
stars: 3
tags:
  - Alibaba
  - OFA
  - M6
  - ICML2022
  - "arxiv:2202.03052"
---

# ofa_sudoku_kaggle_large

> ofa_sudoku_kaggle_large - damo 在 ModelScope 开源的模型。OFA-sudoku 解决方案 数独是什么？ 数独是源自18世纪瑞士的一种数学游戏。是一种运用纸、笔进行演算的逻辑游戏。玩家需要根据9×9盘面上的已知数字，推理出所有剩余空格的数字，并满足每一行、每一列、每一个粗线宫（33）内的数字均含1-9，不重复。…

damo/ofa_sudoku_kaggle_large 是 ModelScope 魔搭社区上的机器学习模型，采用 Apache License 2.0 许可。

- **Repository**: damo/ofa_sudoku_kaggle_large
- **License**: Apache License 2.0
- **Tags**: Alibaba, OFA, M6, ICML2022, arxiv:2202.03052
- **Downloads**: 169
- **Stars**: 3
- **Last updated**: 2025-06-11

Source: https://www.modelscope.cn/models/damo/ofa_sudoku_kaggle_large

---

# OFA-sudoku 解决方案
## 数独是什么？
数独是源自18世纪瑞士的一种数学游戏。是一种运用纸、笔进行演算的逻辑游戏。玩家需要根据9×9盘面上的已知数字，推理出所有剩余空格的数字，并满足每一行、每一列、每一个粗线宫（3*3）内的数字均含1-9，不重复。
<br>
数独盘面是个九宫，每一宫又分为九个小格。在这八十一格中给出一定的已知数字和解题条件，利用逻辑和推理，在其他的空格上填入1-9的数字。使1-9每个数字在每一行、每一列和每一宫中都只出现一次，所以又称“九宫格”。

## 快速玩起来
玩转OFA只需区区以下数行代码，就是如此轻松！如果你觉得还不够方便，请点击右上角`Notebook`按钮，我们为你提供了配备好的环境（可选CPU/GPU），你只需要在notebook里输入提供的代码，就可以把OFA玩起来了！
<p align="center">
    <img src="resources/sudoku-puzzle.png" alt="数独谜题" width="200" />
<p align="center">
    <img src="resources/sudoku-solution.png" alt="数独结果" width="200" />

```python
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.outputs import OutputKeys
ofa_pipe = pipeline(
    Tasks.sudoku,
    model='damo/ofa_sudoku_kaggle_large'
, model_revision='master')
# 有效数字为1-9，要求解的数独位置采用0来初始化输入
# 列与列之间使用` : `分隔符，行与行之间使用` | `分隔符
text = '5 : 3 : 0 : 0 : 7 : 0 : 0 : 0 : 0 | \
        6 : 0 : 0 : 1 : 9 : 5 : 0 : 0 : 0 | \
        0 : 9 : 8 : 0 : 0 : 0 : 0 : 6 : 0 | \
        8 : 0 : 0 : 0 : 6 : 0 : 0 : 0 : 3 | \
        4 : 0 : 0 : 8 : 0 : 3 : 0 : 0 : 1 | \
        7 : 0 : 0 : 0 : 2 : 0 : 0 : 0 : 6 | \
        0 : 6 : 0 : 0 : 0 : 0 : 2 : 8 : 0 | \
        0 : 0 : 0 : 4 : 1 : 9 : 0 : 0 : 5 | \
        0 : 0 : 0 : 0 : 8 : 0 : 0 : 7 : 9'
result = ofa_pipe(text)
print(result[OutputKeys.TEXT])
```
<br>

## OFA-sudoku 模型效果

<table border="1" width="100%">
    <tr align="center">
        <th>Model</th><th>Params</th><th>Accurate</th>
    </tr>
    <tr align="center">
        <td>sudoku-net<sub>v2</sub></td><td>30M</td><td>98.21</td>
    </tr>
    <tr align="center">
        <td>OFA<sub>Base</sub></td><td>180M</td><td>97.92</td>
    </tr>
    <tr align="center">
        <td>OFA<sub>Large</sub></td><td>470M</td><td>99.81</td>
    </tr>
</table>
<br>

## OFA是什么？
OFA(One-For-All)是通用多模态预训练模型，使用简单的序列到序列的学习框架统一模态（跨模态、视觉、语言等模态）和任务（如图片生成、视觉定位、图片描述、图片分类、文本生成等），详见我们发表于ICML 2022的论文：[OFA: Unifying Architectures, Tasks, and Modalities Through a Simple Sequence-to-Sequence Learning Framework](https://arxiv.org/abs/2202.03052)，以及我们的官方Github仓库[https://github.com/OFA-Sys/OFA](https://github.com/OFA-Sys/OFA )。

<p align="center">
    <br>
    <img src="resources/OFA_logo_tp_path.svg" width="150" />
    <br>
<p>
<br>

<p align="center">
        <a href="https://github.com/OFA-Sys/OFA">Github</a>&nbsp ｜ &nbsp<a href="https://arxiv.org/abs/2202.03052">Paper </a>&nbsp ｜ &nbspBlog
</p>

<p align="center">
    <br>
        <video src="https://xingchen-data.oss-cn-zhangjiakou.aliyuncs.com/maas/resources/modelscope_web/demo.mp4" loop="loop" autoplay="autoplay" muted width="80%"></video>
    <br>
</p>

### OFA模型规模：

<table border="1" width="100%">
    <tr align="center">
        <th>Model</th><th>Params-en</th><th>Params-zh</th><th>Backbone</th><th>Hidden size</th><th>Intermediate size</th><th>Num. of heads</th><th>Enc layers</th><th>Dec layers</th>
    </tr>
    <tr align="center">
        <td>OFA<sub>Tiny</sub></td><td>33M</td><td>-</td><td>ResNet50</td><td>256</td><td>1024</td><td>4</td><td>4</td><td>4</td>
    </tr>
    <tr align="center">
        <td>OFA<sub>Medium</sub></td><td>93M</td><td>-</td><td>ResNet101</td><td>512</td></td><td>2048</td><td>8</td><td>4</td><td>4</td>
    </tr>
    <tr align="center">
        <td>OFA<sub>Base</sub></td><td>180M</td><td>160M</td><td>ResNet101</td><td>768</td></td><td>3072</td><td>12</td><td>6</td><td>6</td>
    </tr>
    <tr align="center">
        <td>OFA<sub>Large</sub></td><td>470M</td><td>440M</td><td>ResNet152</td><td>1024</td></td><td>4096</td><td>16</td><td>12</td><td>12</td>
    </tr>
    <tr align="center">
        <td>OFA<sub>Huge</sub></td><td>930M</td><td>-</td><td>ResNet152</td><td>1280</td></td><td>5120</td><td>16</td><td>24</td><td>12</td>
    </tr>
</table>
<br>

## 模型训练流程

### 训练数据介绍
本模型训练数据集是kaggle的sudoku数据集。

### 训练流程
finetune能力请参考[OFA Tutorial](https://www.modelscope.cn/docs/OFA%20Tutorial ) 1.4节。

## 模型局限性以及可能的偏差
训练数据集自身有局限，有可能产生一些偏差，请用户自行评测后决定如何使用。

## 相关论文以及引用信息
如果你觉得OFA好用，喜欢我们的工作，欢迎引用：

```
@article{wang2022ofa,
  author    = {Peng Wang and
               An Yang and
               Rui Men and
               Junyang Lin and
               Shuai Bai and
               Zhikang Li and
               Jianxin Ma and
               Chang Zhou and
               Jingren Zhou and
               Hongxia Yang},
  title     = {OFA: Unifying Architectures, Tasks, and Modalities Through a Simple Sequence-to-Sequence
               Learning Framework},
  journal   = {CoRR},
  volume    = {abs/2202.03052},
  year      = {2022}
}
```
