PyTorch
English
XLXW commited on
Commit
f928ee9
·
verified ·
1 Parent(s): cc128c1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +64 -3
README.md CHANGED
@@ -1,3 +1,64 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ datasets:
4
+ - togethercomputer/RedPajama-Data-1T
5
+ language:
6
+ - en
7
+ base_model:
8
+ - openai-community/gpt2
9
+ ---
10
+
11
+ ## Model Information
12
+
13
+ The ASE collection of language models is a collection of pretrained models for assessing association strength. More details can be found in [CxGLearner](https://learner.xlxw.org/) .
14
+
15
+ **Model developer**: [ZJU MMF (CxGrammar)](https://github.com/CxGrammar)
16
+
17
+ **Model Architecture:** GPT-2 (6 layers)
18
+
19
+ **Supported languages:** English
20
+
21
+ **License:** MIT
22
+
23
+ ## Use with cxglearner
24
+
25
+ Starting with `cxglearner >= 1.3.2` onward, you can run ASE using cxglearner `Association` module.
26
+
27
+ Make sure to update your cxglearner installation via `pip install --upgrade cxglearner`.
28
+
29
+ ### Example
30
+ ```python
31
+ from cxglearner.config import Config, DefaultConfigs
32
+ from cxglearner.lm import Association
33
+ from cxglearner.encoder import Encoder
34
+ from cxglearner.utils import init_logger
35
+
36
+ config = Config(DefaultConfigs.eng)
37
+ # Set the specific model
38
+ config.lm.output_path = "CxGrammar/ase-gpt-medium-wiki"
39
+
40
+ logger = init_logger(config)
41
+ encoder = Encoder(config, logger)
42
+
43
+ # When instantiating Association, cxglearner will automatically download model parameter files from Huggingface Hub.
44
+ # However, you can also manually download pytorch_model.bin and set the output_path to a local path.
45
+ asso = Association(config, logger, encoder=encoder)
46
+
47
+ example_sentence = "The wetlands can be more"
48
+ select_mask = ['lexical', 'lexical', 'lexical', 'lexical']
49
+ select_mask = [level_map[level] for level in select_mask]
50
+ select_mask_2 = ['upos', 'lexical', 'lexical', 'lexical']
51
+ select_mask_2 = [level_map[level] for level in select_mask_2]
52
+
53
+ encoded = encoder.encode(example_sentence, need_ids=True)
54
+ res = encoder.convert_ids_to_tokens([ele[0] for ele in encoded])
55
+ encoded = encoded[1:]
56
+ inputs_1 = [element[select_mask[i]] for i, element in enumerate(encoded)]
57
+ inputs_2 = [element[select_mask_2[i]] for i, element in enumerate(encoded)]
58
+ inputs1_tensor = torch.Tensor(inputs_1).type(torch.int64)
59
+ inputs2_tensor = torch.Tensor(inputs_2).type(torch.int64)
60
+
61
+ # dynamic candidates
62
+ candidate_dynamic = asso_handler.compute_candidate(inputs_1)
63
+ print(candidate_dynamic)
64
+ ```