使用各种提示策略将简短的Python练习翻译成其他编程语言
Stephen R Piccolo1, Harlan P Stevens1,2
1Department of Biology, Brigham Young University, Provo, UT 84602, USA.
GigaScience
|December 8, 2025
概括
大型语言模型 (LLM) 有效地将Python编程练习翻译成C++,Rust,Julia和JavaScript. 这种自动化代码翻译通过减少手工工作,显著帮助科学研究和教育.
科学领域:
- 计算生物学 计算生物学
- 生物信息学是一种生物信息学.
- 科学计算科学计算
背景情况:
- 生命科学家越来越多地使用编程来进行数据分析,可复制性和协作.
- Python 提供了简单性,而 C++ 和 Rust 则为复杂的计算提供了效率.
- 在语言之间翻译代码是劳动密集型的,激励探索自动化解决方案.
研究的目的:
- 调查大型语言模型 (LLM) 对半自动代码翻译的有效性.
- 评估LLM在将Python编程练习翻译成C++,Rust,Julia和JavaScript方面的表现.
主要方法:
- 使用GPT-4将559个简短的Python编程练习翻译成C++,Rust,Julia和JavaScript.
- 采用了三个提示策略:只有指令,只有代码,以及两者的组合.
- 将翻译代码的输出与原始Python代码进行比较,以确保准确性.
主要成果:
- 基于LLM的代码翻译在所有目标语言中表现出高的成功率.
- 翻译成功率最高的是Rust (99.5%),其次是JavaScript (98.9%),C++ (97.9%) 和Julia (95.0%).
- 促销策略显著影响了翻译的成功,综合方法往往被证明是最有效的.
结论:
- 简单的语言编程程序 (LLM) 是一种有效的工具,可以在语言之间翻译小规模的编程练习,从而减少手工劳动.
- 该研究提供了有价值的,免费可用的代码翻译,以支持科学教育和研究.
- 使用LLM的自动代码翻译显示出对简化计算科学工作流程的承诺.
更多相关视频
相关概念视频
Initiation of Translation
7.8K
7.8K
Initiation of Translation
38.2K
Initiating translation is complex because it involves multiple molecules. Initiator tRNA, ribosomal subunits, and eukaryotic initiation factors (eIFs) are all required to assemble on the initiation codon of mRNA. This process consists of several steps that are mediated by different eIFs.
First, the initiator tRNA must be selected from the pool of elongator tRNAs by eukaryotic initiation factor 2 (eIF2). The initiator tRNA (Met-tRNAi) has conserved sequence elements including modified bases at...
First, the initiator tRNA must be selected from the pool of elongator tRNAs by eukaryotic initiation factor 2 (eIF2). The initiator tRNA (Met-tRNAi) has conserved sequence elements including modified bases at...
38.2K
Improving Translational Accuracy
3.5K
3.5K
Improving Translational Accuracy
14.0K
Base complementarity between the three base pairs of mRNA codon and the tRNA anticodon is not a failsafe mechanism. Inaccuracies can range from a single mismatch to no correct base pairing at all. The free energy difference between the correct and nearly correct base pairs can be as small as 3 kcal/ mol. With complementarity being the only proofreading step, the estimated error frequency would be one wrong amino acid in every 100 amino acids incorporated. However, error frequencies observed in...
14.0K
Exercise and Muscle Performance
2.3K
Exercise induces a range of adaptations in muscle tissue, depending on the type and duration of activity. Such physical training can be broadly categorized into two types: endurance exercises and resistance exercises.
Endurance exercises
Endurance exercises involve running, swimming, or cycling, which require repetitive movements with low force output. When a person engages in endurance exercise, a few noticeable changes occur in their skeletal muscles. For instance, the number of capillaries...
Endurance exercises
Endurance exercises involve running, swimming, or cycling, which require repetitive movements with low force output. When a person engages in endurance exercise, a few noticeable changes occur in their skeletal muscles. For instance, the number of capillaries...
2.3K
Machines: Problem Solving I
661
A toggle clamp is a mechanical device commonly used for holding and clamping objects in various applications, such as woodworking, metalworking, and assembly operations. Consider a toggle clamp subjected to a force of 200 N at the handle. The vertical clamping force can be calculated, provided the dimensions of the toggle clamp are known.
The toggle clamp system is a machine structure consisting of movable, pin-connected multi-force members that form a stabilized system to transmit forces. The...
The toggle clamp system is a machine structure consisting of movable, pin-connected multi-force members that form a stabilized system to transmit forces. The...
661


