facebookresearch / nougat

Implementation of Nougat Neural Optical Understanding for Academic Documents
https://facebookresearch.github.io/nougat/
MIT License
8.81k stars 560 forks source link

Finetune Chinese data with Warning: Found repetitions in sample0 #174

Closed Whalesong-zrs closed 1 month ago

Whalesong-zrs commented 10 months ago

We want to finetune the model with Chinese data and we prepare a small dataset with Chinese mmd and corresponding png to overfitting the model. We edit the tokenizer.json with Chinese characters and load the English embed_token part. However, during the trainging process, the validation process always said Warning: Found repetitions in sample0. What should I do?

lukas-blecher commented 10 months ago

Add a flag for inferencing as follows:

preds = self.model.inference(
            image_tensors=image_tensors,
            return_attentions=False,
+           early_stopping=False,
        )["predictions"]

here: https://github.com/facebookresearch/nougat/blob/47c77d70727558b4a2025005491ecb26ee97f523/lightning_module.py#L88-L91

This will disable the early stopping heuristic described in the paper

Whalesong-zrs commented 10 months ago

OK, I will try it, thanks a lot. : )

JasonKitty commented 7 months ago

I also encountered this problem, may I ask you to use the upstairs method to solve it

Whalesong-zrs commented 7 months ago

I also encountered this problem, may I ask you to use the upstairs method to solve it

It has been alleviated to a certain extent, but it still requires the amount of data.

JasonKitty commented 7 months ago

I also encountered this problem, may I ask you to use the upstairs method to solve it

It has been alleviated to a certain extent, but it still requires the amount of data.

Thank you!

lucasjinreal commented 6 months ago

Does there any opensource Chinese data could be used or synthsised?

Whalesong-zrs commented 6 months ago

Does there any opensource Chinese data could be used or synthsised?

As far as I know, there is not, because there is no tex source file like arxiv, so we convert the Chinese text into mmd, and then generate the corresponding pdf file.

lucasjinreal commented 6 months ago

As far as I know, once we have arxiv raw text, it can be translate into Chinese, and render back by pylatex etc to pdf then converts to png. Have anybody tried it?

Whalesong-zrs commented 6 months ago

As far as I know, once we have arxiv raw text, it can be translate into Chinese, and render back by pylatex etc to pdf then converts to png. Have anybody tried it?

We tried a similar method. First, if we directly translate the tex document, we need to add a series of regular rules, because the English of some tex packages and formulas cannot be translated; and the conversion of mmd-pdf pair is obtained through the original author's method. The rate is relatively low. So we still use the method of getting mmd first, and then getting pdf. We try to replace the text with the translated Chinese in mmd. If we use translation API like google, the cost is a bit high; if we use the translation model for translation, The quality of the translation is again very low.

lucasjinreal commented 6 months ago

HI, I tried using LLM to translate and let it do not translation latex symbols, but it is not faithfull, with lots of hullucinations.

Can u tell how to getiing mmd ? How to convert arvix latex to multi markdown format?

Whalesong-zrs commented 6 months ago

HI, I tried using LLM to translate and let it do not translation latex symbols, but it is not faithfull, with lots of hullucinations.

Can u tell how to getiing mmd ? How to convert arvix latex to multi markdown format?

我们的方法是这样的:mmd本身文本没有什么特别复杂的格式,从中文的文本数据可以直接导入成mmd,再给这个mmd加入一些tex格式需要的头尾,就可以用这个tex文件来渲染出对应的pdf。 Our method is as follows: the text of mmd itself does not have any particularly complicated format. The Chinese text data can be directly imported into mmd, and then some headers and tails required by the tex format are added to this mmd, and then this tex file can be used to render the corresponding pdf.

lucasjinreal commented 6 months ago

,从中文的文本数据可以直接导入成mmd,

这一步有什么工具可以做得到吗?文本如何构造成mmd,有什么template吗

Whalesong-zrs commented 6 months ago

,从中文的文本数据可以直接导入成mmd,

这一步有什么工具可以做得到吗?文本如何构造成mmd,有什么template吗

没有什么好的办法,因为如果只考虑最朴素的文本格式,是不需要什么模板的,mmd本身也不需要像tex引入很多格式包,如果你想加入一些特定的样式,就需要自己设计对应的模板,我们一开始尝试了什么模板也没有,只有文字排列的数据,泛化性很差,所以说想做出泛化性好的中文模型,需要自己去想办法生成尽可能复杂的文本数据。

lucasjinreal commented 6 months ago

mmd可以做到图文混排吗?如果可以的话,那可以直接用mmd渲染出pdf,就可以拿到文本图像对

Whalesong-zrs commented 6 months ago

mmd可以做到图文混排吗?如果可以的话,那可以直接用mmd渲染出pdf,就可以拿到文本图像对

暂时没有考虑插图

dreamlychina commented 3 months ago

,从中文的文本数据可以直接导入成mmd,

这一步有什么工具可以做得到吗?文本如何构造成mmd,有什么template吗

没有什么好的办法,因为如果只考虑最朴素的文本格式,是不需要什么模板的,mmd本身也不需要像tex引入很多格式包,如果你想加入一些特定的样式,就需要自己设计对应的模板,我们一开始尝试了什么模板也没有,只有文字排列的数据,泛化性很差,所以说想做出泛化性好的中文模型,需要自己去想办法生成尽可能复杂的文本数据。

你好,请问下大佬实验的效果怎么样了?

Whalesong-zrs commented 3 months ago

,从中文的文本数据可以直接导入成mmd,

这一步有什么工具可以做得到吗?文本如何构造成mmd,有什么template吗

没有什么好的办法,因为如果只考虑最朴素的文本格式,是不需要什么模板的,mmd本身也不需要像tex引入很多格式包,如果你想加入一些特定的样式,就需要自己设计对应的模板,我们一开始尝试了什么模板也没有,只有文字排列的数据,泛化性很差,所以说想做出泛化性好的中文模型,需要自己去想办法生成尽可能复杂的文本数据。

你好,请问下大佬实验的效果怎么样了?

由于我们的算力限制,我们最近没有进行实验;之前的实验结果证明了我们增加自己生成的数据,能够提高在真实数据的泛化性,但是上次的规模比较小,没有再做验证这种数据的能力是不是已经达到了顶点,我们现在还在生成数据,预计六月底会有一个实验结果

we89 commented 1 month ago

@Whalesong-zrs 大佬,方便的话能加个联系方式详聊一下吗?我们这边也想用中文微调这个模型,我的qq是2695307109,万分感谢!

JasonKitty commented 1 month ago

,从中文的文本数据可以直接导入成mmd,

这一步有什么工具可以做得到吗?文本如何构造成mmd,有什么template吗

没有什么好的办法,因为如果只考虑最朴素的文本格式,是不需要什么模板的,mmd本身也不需要像tex引入很多格式包,如果你想加入一些特定的样式,就需要自己设计对应的模板,我们一开始尝试了什么模板也没有,只有文字排列的数据,泛化性很差,所以说想做出泛化性好的中文模型,需要自己去想办法生成尽可能复杂的文本数据。

你好,请问下大佬实验的效果怎么样了?

由于我们的算力限制,我们最近没有进行实验;之前的实验结果证明了我们增加自己生成的数据,能够提高在真实数据的泛化性,但是上次的规模比较小,没有再做验证这种数据的能力是不是已经达到了顶点,我们现在还在生成数据,预计六月底会有一个实验结果

实验结果如何?

Whalesong-zrs commented 1 month ago

,从中文的文本数据可以直接导入成mmd,

这一步有什么工具可以做得到吗?文本如何构造成mmd,有什么template吗

没有什么好的办法,因为如果只考虑最朴素的文本格式,是不需要什么模板的,mmd本身也不需要像tex引入很多格式包,如果你想加入一些特定的样式,就需要自己设计对应的模板,我们一开始尝试了什么模板也没有,只有文字排列的数据,泛化性很差,所以说想做出泛化性好的中文模型,需要自己去想办法生成尽可能复杂的文本数据。

你好,请问下大佬实验的效果怎么样了?

由于我们的算力限制,我们最近没有进行实验;之前的实验结果证明了我们增加自己生成的数据,能够提高在真实数据的泛化性,但是上次的规模比较小,没有再做验证这种数据的能力是不是已经达到了顶点,我们现在还在生成数据,预计六月底会有一个实验结果

实验结果如何?

还是泛化性不够,在真实数据的效果很差