Skip to main content
zenodoopen

Replication package of the paper "Do LLMs Provide Links to Code Similar to what they Generate? A Study with Gemini and Bing CoPilot"

<h1>Replication Package</h1> <p>This replication package contains the necessary tools, data, and scripts for reproducing the results of our paper: "<em>Do LLMs Provide Links to Code Similar to what they Generate? A Study with Gemini and Bing CoPilot</em>". Below is a detailed description of the directory structure and the contents of this package.</p> <h2>Contents</h2> <p>The replication package is organized into two main directories:</p> <ul> <li> <p><code>assets</code>: This directory contains all .csv files used as input for the script and the outputted .csv file used to perform the manual and automated analyses for RQ1 and RQ2.</p> </li> <li> <p><code>script</code>: This directory contains all scripts for RQ1 and RQ2.</p> </li> </ul> <p>In the following, we describe the content of each directory:</p> <h2><code>assets</code></h2> <p>This directory contains the tools and resources required for our study.</p> <h3><code>dataset</code>: Contains the main datasets used in the study.</h3> <ul> <li> <p><code>annotationStore.csv</code>: Input dataset for our analyses, originating from the <em>CODESEARCHNET</em> dataset.</p> </li> <li> <p><code>queries.csv</code>: .csv file containing the queries used for the experiments filtered from the <em>CODESEARCHNET</em>dataset. This file contains the following columns:</p> <ul> <li><em>Language</em>: Programming language of the query</li> <li><em>Query</em>: Query used for the experiment</li> <li><em>GitHubUrl</em>: GitHub URL related to a snippet that addresses the query</li> <li><em>Relevance</em>: Relevance of the linked GitHub snippet to the query</li> </ul> </li> </ul> <h3><code>data</code>: Contains the datasets and results of all analyses.</h3> <ul> <li> <p><code>queries.csv</code>: General input queries. This file contains the following columns:</p> <ul> <li><em>Language</em>: Programming language of the query</li> <li><em>Query</em>: Query used for the snippet generation</li> <li><em>Prompt</em>: LLM prompt generated for the query as: <em>You are a Senior <code>&lt;Language&gt;</code> developer. Then give me a <code>&lt;Language&gt;</code> code snippet about: <code>&lt;Query&gt;</code></em></li> </ul> </li> <li> <p><code>queries_filled.csv</code>: Similar to the previous file, but also containing the output produced by the LLM-based assistants. This file contains the following columns:</p> <ul> <li><em>Language</em>: Programming language of the query</li> <li><em>Query</em>: Query used for the snippet generation</li> <li><em>Prompt</em>: LLM prompt generated for the query as: <em>You are a Senior <code>&lt;Language&gt;</code> developer. Then give me a <code>&lt;Language&gt;</code> code snippet about: <code>&lt;Query&gt;</code></em></li> <li><em>Notes</em>: General notes that provide additional context or information about the query or prompt.</li> <li><em>Gemini_Answer(n)</em>: The generated code snippets by Gemini.</li> <li><em>Gemini(n)</em>: The external links provided by Gemini.</li> <li><em>Prompt (repeated)</em></li> <li><em>Note</em>: Notes that provide additional context or information about the query or prompt.</li> <li><em>Copilot_Answer(n)</em>: The generated code snippets by Bing-Copilot.</li> <li><em>Copilot_Bing(n)</em>: The external links provided by Bing-Copilot.</li> </ul> </li> </ul> <h4><code>copilot</code> || <code>gemini</code>: Contains the data related to the specific LLM. These two subdirectories have the same internal structure.</h4> <ul> <li><code>queries.csv</code>: The <code>queries_filled.csv</code> file, filtered for the specific LLM.</li> <li><code>queries_noTrivial.csv</code>: Contains only the queries with at least one nontrivial generated snippet.</li> <li> <p><code>external_links.csv</code>: External links extracted from the LLMs output.</p> </li> <li> <p><code>external_links_filled.csv</code>: Snippets extracted from the external links.</p> <ul> <li><em>index</em>: Query ID</li> <li><em>source</em>: Snippet ID</li> <li><em>url</em>: Link URL</li> <li><em>note</em>: Notes that provide additional context or information about the query or prompt</li> <li><em>code(n)</em>: The n-th code snippet extracted from the source</li> </ul> </li> </ul> <h4><code>manual_analysis</code>: Manual analysis results.</h4> <ul> <li><code>manual_analysis.csv</code>: <ul> <li><em>index</em>: Query ID</li> <li><em>query</em>: Query used for the snippet generation</li> <li><em>generatedsnippet(n)</em>: The n-th code snippet generated by the LLM-based assistant</li> <li><em>trivial_1</em>: Manual analysis of whether or not the snippet was trivial (validator 1)</li> <li><em>trivial_2</em>: Manual analysis of whether or not the snippet was trivial (validator 2)</li> <li><em>trivial_final</em>: Manual analysis of whether or not the snippet was trivial (final classification if there is a disagreement)</li> <li><em>source</em>: URL to analyze</li> <li><em>sourcetype1</em>: Type of the source (validator 1)</li> <li><em>sourcetype2</em>: Type of the source (validator 2)</li> <li><em>sourcetypefinal</em>: Type of the source (final classification if there is a disagreement)</li> <li><em>relatedtoquery_1</em>: Relevance of the link to the query (validator 1)</li> <li><em>relatedtoquery_2</em>: Relevance of the link to the query (validator 2)</li> <li><em>relatedtoquery_final</em>: Relevance of the link to the query (final classification if there is a disagreement)</li> <li><em>relatedtosnippets_1</em>: Relevance of the generated snippet to those in the link (validator 1)</li> <li><em>relatedtosnippets_2</em>: Relevance of the generated snippet to those in the link (validator 2)</li> <li><em>relatedtosnippets_final</em>: Relevance of the generated snippet to those in the link (final classification if there is a disagreement)</li> </ul> </li> <li><code>manual_analysis_noTrivial.csv</code>: As in the previous file, but only the queries with at least one nontrivial generated code snippet.</li> </ul> <h4><code>clone_detector</code>: Output and intermediate files for clone detection with Copilot data.</h4> <ul> <li><code>copilot_tokens || gemini_tokens</code>: Contains the output the tokenization of the generated code snippets and the code snippets extracted from the external links.</li> <li><code>merged_llm_ext_link.csv</code>: All possible pairs (Cartesian product) (code snippet extracted from the external links, generated code snippet). This file is the input of the clone detection tool. <ul> <li><em>ID_query</em>: Query ID</li> <li><em>query</em>: Query used for the snippet generation</li> <li><em>language</em>: Programming language of the query</li> <li><em>generated_snippet</em>: The generated code snippet by the LLM-based assistant</li> <li><em>IDgensnippet</em>: The index of the generated code snippet</li> <li><em>LOCgensnippet</em>: The number of lines of code of the generated code snippet</li> <li><em>ID_source</em>: Source ID</li> <li><em>source</em>: Source URL</li> <li><em>source_snippet</em>: Code snippet extracted from the source</li> <li><em>IDsourcesnippet</em>: ID of the code snippet extracted from the source</li> <li><em>LOCsourcesnippet</em>: The number of lines of code of the code snippet extracted from the source</li> <li><em>note</em>: Notes that provide additional context or information about the query or prompt</li> </ul> </li> <li><code>clone_detection_output.csv</code>: Contains the clone detection results. <ul> <li><em>ID_query</em>: The index of the query</li> <li><em>query</em>: Query used for the snippet generation</li> <li><em>language</em>: The programming language of the query</li> <li><em>generated_snippet</em>: The generated code snippet by the LLM-based assistant</li> <li><em>IDgensnippet</em>: The index of the generated code snippet</li> <li><em>LOCgensnippet</em>: The number of lines of code of the generated code snippet</li> <li><em>ID_source</em>: Source ID</li> <li><em>source</em>: Source URL</li> <li><em>source_snippet</em>: Code snippet extracted from the source</li> <li><em>IDsourcesnippet</em>: ID of the code snippet extracted from the source</li> <li><em>LOCsourcesnippet</em>: The number of lines of code of the code snippet extracted from the source</li> <li><em>note</em>: Notes that provide additional context or information about the query or prompt</li> <li><em>clone_detected</em>: bBolean value that indicates whether a clone has been detected (1 = detected, 0 = not detected)</li> <li><em>cloning_ratio</em>: Ratio of the number of lines of code of the generated code snippet has been detected as a clone in the code snippet extracted from the source</li> <li><em>cloned_lines</em>: The number of lines of code of the generated code snippet that has been detected as a clone in the code snippet extracted from the source</li> </ul> </li> </ul> <h4><code>cosine_sim</code>: Cosine similarity results.</h4> <ul> <li><code>cosine_sim_output.csv</code>: Contains the cosine similarity results <ul> <li><em>query_id</em>: Query ID</li> <li><em>snippet_id</em>:ID the generated code snippet</li> <li><em>source_id</em>: ID of the source</li> <li><em>sourcesnippetid</em>: ID of the code snippet extracted from the source <ul> <li><em>cosine_similarity</em>: The cosine similarity between the generated code snippet and the code snippet extracted from the source</li> </ul> </li> </ul> </li> </ul> <h4><code>quant_analysis</code>: Quantitative analysis results.</h4> <ul> <li><code>topN_links_se.csv</code>: Contains the top-N links extracted from the search engine. <ul> <li><em>id</em>: Query ID</li> <li><em>query</em>: The query</li> <li><em>url</em>: Link URL</li> </ul> </li> <li><code>merged_clone_cosine.csv</code>: Contains the merged results of the clone detection and cosine similarity. <ul> <li><em>ID_query</em>: Query ID</li> <li><em>query</em>: The query</li> <li><em>language</em>: The programming language of the query</li> <li><em>generated_snippet</em>: The generated code snippet by the LLM-based assistant</li> <li><em>IDgensnippet</em>: The ID of the generated code snippet</li> <li><em>LOCgensnippet</em>: The number of lines of code of the generated code snippet</li> <li><em>ID_source</em>: The index of the source</li> <li><em>source</em>: The source URL</li> <li><em>source_snippet</em>: The code snippet extracted from the source</li> <li><em>IDsourcesnippet</em>: The index of the code snippet extracted from the source</li> <li><em>LOCsourcesnippet</em>: The number of lines of code of the code snippet extracted from the source</li> <li><em>note</em>: Notes that provide additional context or information about the query or prompt</li> <li><em>clone_detected</em>: Boolean value that indicates if a clone has been detected(1 = detected, 0 = not detected)</li> <li><em>cloning_ratio</em>: The ratio of the number of lines of code of the generated code snippet has been detected as a clone in the code snippet extracted from the source</li> <li><em>cloned_lines</em>: The number of lines of code of the generated code snippet that has been detected as a clone in the code snippet extracted from the source</li> <li><em>cosine_similarity</em>: The cosine similarity between the generated code snippet and the code snippet extracted from the source</li> </ul> </li> </ul> <h4><code>other_analysis</code>: Contains more performed analysis.</h4> <ul> <li><code>sample_queries.csv</code>: Contains a sample of five queries for language used for perform the chain of thought experiment. <ul> <li><em>Language</em>: Programming language of the query</li> <li><em>Query</em>: Query used for the snippet generation</li> <li><em>Prompt</em>: LLM prompt generated for the query as: <em>You are a Senior <code>&lt;Language&gt;</code> developer. Then give me a <code>&lt;Language&gt;</code> code snippet about: <code>&lt;Query&gt;</code></em></li> </ul> </li> <li><code>chain_of_thought.csv</code>: <ul> <li><em>Language</em>: Programming language of the query</li> <li><em>Query</em>: Query used for the snippet generation</li> <li><em>Prompt</em>: LLM prompt generated for the query as: <em>You are a Senior <code>&lt;Language&gt;</code> developer. Then give me a <code>&lt;Language&gt;</code> code snippet about: <code>&lt;Query&gt;</code></em></li> <li><em>Clone_fonud</em>: Boolean value that indicates if a clone has been detected (Yes = detected, No = not detected)</li> <li><em>Note</em>: Notes that provide additional context or information about the performed analysis</li> </ul> </li> <li><code>data_check.csv</code>: <ul> <li><em>Link</em>: URL of the source provided by the LLM</li> <li><em>Post_date</em>: Indicates if the date of the post is before/after the date of training of the LLM (before 2023, after 2023, not provided)</li> <li><em>Note</em>: Notes that provide additional context or information about the performed analysis</li> </ul> </li> </ul> <h4><code>results</code>: Final analysis results.</h4> <ul> <li><code>jaccard_analysis.csv</code>: Contains the results of the Jaccard analysis comparing the provided external links by the LLMs with the top-N links extracted from the corresponding search engine. <ul> <li><em>id</em>: Query ID</li> <li><em>language</em>: The programming language of the query</li> <li><em>llm_link</em>: The external links provided by the LLM</li> <li><em>llmlinksize</em>: The number of external links provided by the LLM</li> <li><em>overlap_links</em>: The overlapping links between the LLM and the search engine</li> <li><em>overlap_size</em>: The number of overlapping links between the LLM and the search engine</li> <li><em>nonoverlaplinks</em>: The non-overlapping links between the LLM and the search engine</li> <li><em>union_size</em>: The size of the union set links between the LLM and the search engine</li> <li><em>jaccard</em>: The Jaccard similarity between the LLM and the search engine</li> </ul> </li> <li><code>merged_analysis.csv</code>: Contains the merged results of the manual and quantitative analyses. <ul> <li><em>id</em>: The index of the query</li> <li><em>query</em>: The query used for the experiment</li> <li><em>trivial_final(n)</em>: The final assignment for the triviality of the n-th generated code snippet</li> <li><em>source</em>: The URL of the source</li> <li><em>sourcetypefinal</em>: The final assignment for the type of the source</li> <li><em>relatedtoquery_final</em>: The final assignment for the relevance of the generated code snippet to the query</li> <li><em>relatedtosnippets_final</em>: The final assignment for the relevance of the generated code snippet to the source</li> <li><em>cloning_ratio</em>: The maximum cloning ratio between the generated code snippet and all the code snippets extracted from the source</li> <li><em>cosine_similarity</em>: The cosine similarity related to the snippets with maximum cloning ratio</li> </ul> </li> </ul> <h3><code>cccfindersw-configuration-files</code>:</h3> <p>Contains additional configuration files for the CCFinderSW clone detection tool. The files are <code>javascript_comment.txt</code> and <code>javascript_reserved.txt</code>. They must be placed in the tool's <code>comment/</code> and <code>reserved/</code> directories.</p> <h3><code>appendix.tex</code>: The appendix of the paper containing:</h3> <ul> <li><em>Table 1</em>: Number of links of different types provided by Gemini and Bing CoPilot</li> </ul> <h3><code>appendix.pdf</code>: The appendix of the paper in PDF format.</h3> <h2><code>script</code></h2> <p>This directory contains our scripts (mostly Python, an R script and an Applescript) to preprocess data and run the clone detection analyses.</p> <ul> <li><code>1_dateset_filtering.py</code>: Script to filter the dataset. The input of this script is the <code>annotationStore.csv</code> file, and the output is the <code>queries.csv</code> file.</li> <li><code>2_prompt_generation.py</code>: Script to generate prompts for the LLM-based assistants. The input of this script is the <code>queries.csv</code> file, and the output is the <code>queries_filled.csv</code> file.</li> <li><code>3_gen_sheet_sources_extraction.py</code>: Script to split the external links provided by the LLM, one for each row. The input of this script is the <code>queries_filled.csv</code> file, and the output is the <code>external_link.csv</code> file.</li> <li><code>4_ext_link_snippet_extraction.py</code>: Script to extract the snippets from Web URLs. It only works for the most popular domains. The input of this script is the <code>external_links.csv</code> file, and the output is the <code>external_links_filled.csv</code> file.</li> <li><code>5_top_n_link_SearchEngine.py</code>: Script to perform top-N link search using the corresponding search engines (Google Search and Bing). The input of this script is the <code>queries_filled.csv</code> file. It executes the <code>browser_bot.scpt</code>. The output is the <code>topN_links_se.csv</code> file. <ul> <li><code>browser_bot.scpt</code>: Script for browser automation (AppleScript).</li> </ul> </li> <li><code>6_se_vs_llm.py</code>: Script to compare (using the Jaccard metric) the links returned by the corresponding search engines with those provided by the LLM-based assistants. The input of this script is the <code>external_links.csv</code> file and the <code>topN_links_se.csv</code> file. The output is the <code>jaccaard_analysis.csv</code> file.</li> <li><code>7_results_manual_analysis.py</code>: Script to extract results and statistical analyses performed on the manual analysis and reported in the tables in the paper.</li> <li><code>8_merge_gen_source_snippets.py</code>: This script takes as input: <code>{llm}/queries.csv</code> and <code>{llm}/external_link_filled.csv</code> to merge them and generates an expanded one, i.e., one in which we have on each line a snippet extracted from the source, this will be the input of our final script for clone detection. The output is the <code>merged_llm_ext_link.csv</code> file.</li> <li><code>9_clone_detection.py</code>: Script to perform clone detection. The input of this script is the <code>merged_llm_ext_link.csv</code> file, and the output is the <code>clone_detection_output.csv</code> file.</li> <li><code>10_cosine_sim_check.py</code>: Script to compute the code snippets' cosine similarity. The script takes as input the tokenized files from the <code>{llm}_tokens</code> directory. The output is the <code>cosine_sim_output.csv</code>file.</li> <li><code>11_merger_clone_cosine.py</code>: Script to merge clone detection and cosine similarity results. The input of this script is the <code>clone_detection_output.csv</code> and the <code>cosine_sim_output.csv</code> files, and the output is the <code>merged_clone_cosine.csv</code> file.</li> <li><code>12_merge_manual_quantitative_analysis.py</code>: Script to merge manual and quantitative analysis results. The inputs of this script are the <code>manual_analysis.csv</code> and the <code>merged_clone_cosine.csv</code>files, and the output is the <code>merged_analysis.csv</code> file.</li> <li><code>13_sample_for_COT_analysis.py</code>: Script to collect the sample of queries on which we perform the chain of thought analysis, the output is the <code>sample_queries.csv</code> file.</li> <li><code>14_llm_vs_csn.py</code>: Script to check the overlap between the links provided by the LLM and the one associated with the related query in the <em>CodeSearchNet</em> dataset. The input of this script is the <code>queries.csv</code>and <code>queries_noTrivial.csv</code> file.</li> <li><code>cloningGraph.R</code>: R script to generate the cloning graph. The input of this script is the <code>merged_analysis.csv</code> file.</li> </ul>

ShareScore

32/100

Overall dataset sharing score

Score breakdown

These five areas show where the dataset supports — or may limit — practical reuse.

Stewardship
4
Harmonization
4
Access
16
Reuse readiness
8
Engagement
0