PEFT
cdh commited on
Commit
41a7ee2
·
verified ·
1 Parent(s): 2d51056

Added model card

Browse files
Files changed (1) hide show
  1. README.md +98 -3
README.md CHANGED
@@ -1,3 +1,98 @@
1
- ---
2
- license: openrail
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: openrail
3
+ datasets:
4
+ - universal-dependencies/universal_dependencies
5
+ language:
6
+ - bg
7
+ - ca
8
+ - zh
9
+ - hr
10
+ - cs
11
+ - da
12
+ - nl
13
+ - en
14
+ - fi
15
+ - fr
16
+ - de
17
+ - hu
18
+ - id
19
+ - it
20
+ - ja
21
+ - ko
22
+ - 'no'
23
+ - pl
24
+ - pt
25
+ - ro
26
+ - ru
27
+ - sl
28
+ - es
29
+ - sv
30
+ - uk
31
+ base_model:
32
+ - meta-llama/Llama-2-13b-hf
33
+ ---
34
+
35
+ # Introduction
36
+ The paper explores the capabilities of Large Language Models (LLMs) like LLaMA in syntactic parsing tasks. We introduce U-DepPLLaMA, a novel architecture that treats Dependency Parsing as a sequence-to-sequence problem, achieving state-of-the-art results in 26 languages from the Universal Dependency Treebank. Our approach demonstrates that LLMs can handle dependency parsing without the need for specialized architectures, showing robust performance even with complex sentence structures. The paper is available [here](https://journals.openedition.org/ijcol/1352).
37
+
38
+ For more details, please consult the associated [Github repository](https://github.com/crux82/u-deppllama).
39
+
40
+ # How to use it
41
+
42
+ ```Python
43
+ model = AutoModelForCausalLM.from_pretrained(
44
+ "meta-llama/Llama-2-13b-hf",
45
+ load_in_4bit=True,
46
+ quantization_config=quant_config,
47
+ torch_dtype=torch.float16,
48
+ trust_remote_code=True,
49
+ device_map={"": 0},
50
+ )
51
+ model = PeftModel.from_pretrained(
52
+ model,
53
+ "sag-uniroma2/u-depp-llama-2-13b"
54
+ )
55
+
56
+ input_string = "He was most widely recognized for some of his books."
57
+ prompt = f"""
58
+ ### Input:
59
+ {input_string}
60
+ ### Answer:"""
61
+
62
+ inputs = tokenizer(prompt, return_tensors="pt", padding=do_padding, truncation=True, max_length=CUTOFF_LEN)
63
+ input_ids = inputs["input_ids"].to(model.device)
64
+
65
+ with torch.no_grad():
66
+ gen_outputs = model.generate(
67
+ input_ids=input_ids,
68
+ generation_config=generation_config,
69
+ return_dict_in_generate=True,
70
+ output_scores=True,
71
+ max_new_tokens=MAX_NEW_TOKENS,
72
+ use_cache=True,
73
+ )
74
+ s = gen_outputs.sequences[0]
75
+ output = tokenizer.decode(s, skip_special_tokens=True)
76
+
77
+ if "### Answer:" in output:
78
+ response = output.split("### Answer:")[1].rstrip().lstrip()
79
+ else:
80
+ response = "UNK"
81
+ print("WARNING")
82
+ print(row)
83
+ print(output)
84
+ print("\n--------------------\n")
85
+ ```
86
+
87
+ # Citation
88
+ ```
89
+ @article{hromei2024udeppllama,
90
+ author = "Hromei, Claudiu Daniel and Croce, Danilo and Basili, Roberto",
91
+ title = "U-DepPLLaMA: Universal Dependency Parsing via Auto-regressive Large Language Models",
92
+ journal = "IJCoL",
93
+ year = 2024,
94
+ volume = "10",
95
+ number = "1",
96
+ pages = "21--38"
97
+ }
98
+ ```