File size: 1,568 Bytes
74050b1
31601e3
 
 
 
 
 
 
74050b1
31601e3
 
 
753278f
31601e3
 
 
 
 
 
 
 
 
 
753278f
 
31601e3
 
 
 
 
 
 
 
0133996
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31601e3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Model card for CoNN Parity


### Introduction
In paper Neural Comprehension: Language Models with Compiled Neural Networks , we introduced the integration of Compiled Neural Networks (CoNN) into the framework of language models, enabling existing language models to perform symbolic operations with perfect accuracy without the need for external tools. In this model card, we introduce the Parity model, which is similar to the Transformer model and can be used to perform the Parity task.



### Install 

```
git clone https://github.com/WENGSYX/Neural-Comprehension
cd Neural-Comprehension
pip install .
```

To run neural comprehension, you need to install `PyTorch`, `Transformers`, `jax`, and `tracr`.



### How to Use?

```
from NeuralCom.CoNN.modeling_conn import CoNNModel
from NeuralCom.CoNN import Tokenizer


model = CoNNModel.from_pretrained('WENGSYX/CoNN_Parity')
tokenizer = Tokenizer(model.config.input_encoding_map, model.config.output_encoding_map,model.config.max_position_embeddings)

output = model(tokenizer('1 1 0 0 1 0').unsqueeze(0))
print(tokenizer.decode(output.argmax(2)))
>>> [['bos', '1', '1', '1', '1', '1', '1']]
```


### 🙏Cite🙏


###### If you are interested in our paper, please feel free to cite it.
```
@misc{weng2023neural,
      title={Neural Comprehension: Language Models with Compiled Neural Networks}, 
      author={Yixuan Weng and Minjun Zhu and Fei Xia and Bin Li and Shizhu He and Kang Liu and Jun Zhao},
      year={2023},
      eprint={2304.01665},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
```