You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is the code and data for NL-code-search-WebQuery task.
1
+
# CodeXGLUE -- Code Search (WebQueryTest)
4
2
5
3
## Task Description
6
4
7
-
Code Search is aimed to find a code snippet which best matches the demand of the query. This task can be formulated in two scenarios: retrieval scenario and text-code classification scenario. In NL-code-search-WebQuery, we present the Code Search in text-code classification scenario.
5
+
Code Search is aimed to find a code snippet which best matches the demand of the query. This task can be formulated in two scenarios: retrieval scenario and text-code classification scenario. In WebQueryTest , we present the Code Search in text-code classification scenario.
8
6
9
-
In NL-code-search-WebQuery, a trained model needs to judge whether a code snippet answers a given natural language query, which can be formulated into a binary classification problem.
7
+
In WebQueryTest, a trained model needs to judge whether a code snippet answers a given natural language query, which can be formulated into a binary classification problem.
10
8
11
-
Most existing code search datasets use code documentations or questions from online communities for software developers as queries, which is still different from real user search queries. Therefore we provide NL-code-searhc-WebQuery testing set.
9
+
Most existing code search datasets use code documentations or questions from online communities for software developers as queries, which is still different from real user search queries. Therefore we provide WebQueryTest testing set.
12
10
13
11
## Dependency
14
12
@@ -19,9 +17,9 @@ Most existing code search datasets use code documentations or questions from o
19
17
20
18
## Data
21
19
22
-
Here we present NL-code-search-WebQuery dataset, a testing set of Python code search of 1,046 query-code pairs with code search intent and their human annotations. The realworld user queries are collected from Bing query logs and the code for queries are from CodeSearchNet. You can find our testing set in `./data/test_webquery.json` .
20
+
Here we present WebQueryTest dataset, a testing set of Python code search of 1,046 query-code pairs with code search intent and their human annotations. The realworld user queries are collected from Bing query logs and the code for queries are from CodeSearchNet. You can find our testing set in `./data/test_webquery.json` .
23
21
24
-
Since there's no direct training set for our WebQueryTest set, we finetune the models on an external training set by using the documentation-function pairs in the training set o fCodeSearchNet AdvTest as positive instances. For each documentation, we also randomly sample 31 more functions to form negative instances. You can run the following command to download and preprocess the data:
22
+
Since there's no direct training set for our WebQueryTest dataset, we finetune the models on an external training set by using the documentation-function pairs in the training set o CodeSearchNet AdvTest as positive instances. For each documentation, we also randomly sample 31 more functions to form negative instances. You can run the following command to download and preprocess the data:
25
23
26
24
```shell
27
25
cd data
@@ -36,11 +34,11 @@ cd ..
36
34
37
35
#### Data statistics
38
36
39
-
Data statistics of NL-code-search-WebQuery are shown in the table below:
37
+
Data statistics of WebQueryTest are shown in the table below:
40
38
41
-
|| #Examples |
42
-
| -------------| :-------: |
43
-
|test_webquery| 1,046 |
39
+
|| #Examples |
40
+
|:----------:| :-------: |
41
+
|WebQueryTest| 1,046 |
44
42
45
43
46
44
## Fine-tuning
@@ -50,73 +48,81 @@ You can use the following command to finetune:
50
48
```shell
51
49
python code/run_classifier.py \
52
50
--model_type roberta \
53
-
--task_name webquery \
54
51
--do_train \
55
52
--do_eval \
56
53
--eval_all_checkpoints \
57
-
--train_file train_codesearchnet_31.json \
58
-
--dev_file dev_codesearch_net.json \
54
+
--train_file train_codesearchnet_7.json \
55
+
--dev_file dev_codesearchnet.json \
59
56
--max_seq_length 200 \
60
-
--per_gpu_train_batch_size 32 \
61
-
--per_gpu_eval_batch_size 32 \
57
+
--per_gpu_train_batch_size 16 \
58
+
--per_gpu_eval_batch_size 16 \
62
59
--learning_rate 1e-5 \
63
60
--num_train_epochs 3 \
64
-
--gradient_accumulation_steps 1 \
61
+
--gradient_accumulation_steps 1 \
65
62
--warmup_steps 5000 \
66
-
--overwrite_output_dir \
63
+
--evaluate_during_training \
67
64
--data_dir ./data/ \
68
-
--output_dir ./model/ \
69
-
--model_name_or_path microsoft/codebert-base \
70
-
--config_name roberta-base
65
+
--output_dir ./model \
66
+
--encoder_name_or_path microsoft/codebert-base
71
67
72
68
```
73
69
74
70
## Evaluation
75
71
76
-
To test on the WebQuery testset, you run the following command. Also it will automatically generate predictions to `--prediction_file`.
72
+
To test on the WebQueryTest, you run the following command. Also it will automatically generate predictions to `--prediction_file`.
0 commit comments