Lazyhope commited on
Commit
8442c47
1 Parent(s): d0e1e46

Add pipeline usage to the model card

Browse files
Files changed (1) hide show
  1. README.md +23 -1
README.md CHANGED
@@ -7,7 +7,29 @@ This is a codebert model for detecting Python clone codes, fine-tuned on the dat
7
 
8
  # How to use
9
 
10
- To use the model, you can follow the instructions in the original source code at https://github.com/sangHa0411/CloneDetection/blob/main/inference.py. A more general inference code may be published later.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  # Credits
13
 
 
7
 
8
  # How to use
9
 
10
+ To use the model, you can follow the original inference source code at https://github.com/sangHa0411/CloneDetection/blob/main/inference.py.
11
+
12
+ More conveniently, a pipeline for this model has been implemented, and you can initialize it with only two lines of code:
13
+ ```python
14
+ from transformers import pipeline
15
+
16
+ pipe = pipeline(model="Lazyhope/python-clone-detection", trust_remote_code=True)
17
+ ```
18
+ To use it, pass a tuple of code pairs:
19
+ ```python
20
+ code1 = """def token_to_inputs(feature):
21
+ inputs = {}
22
+ for k, v in feature.items():
23
+ inputs[k] = torch.tensor(v).unsqueeze(0)
24
+
25
+ return inputs"""
26
+ code2 = """def f(feature):
27
+ return {k: torch.tensor(v).unsqueeze(0) for k, v in feature.items()}"""
28
+
29
+ is_clone = pipe((code1, code2))
30
+ is_clone
31
+ # {False: 1.3705984201806132e-05, True: 0.9999862909317017}
32
+ ```
33
 
34
  # Credits
35