Expand description
Compiler-in-the-Loop Learning (CITL) for transpiler support. Compiler-in-the-Loop Learning (CITL) module.
This module provides infrastructure for self-supervised learning using compiler feedback as an automatic labeling oracle.
§Architecture
The CITL module is organized around these core abstractions:
CompilerInterface: Universal interface for any compiler backendCompilerDiagnostic: Structured representation of compiler errorsErrorEncoder: Encodes errors into embeddings for pattern matchingPatternLibrary: Stores learned error-fix patterns with HNSW indexFixGenerator: Generates fixes using retrieval-augmented generation
§Example
ⓘ
use aprender::citl::{CITL, RustCompiler, CompilationMode};
// Initialize CITL with Rust compiler
let citl = CITL::builder()
.compiler(RustCompiler::new().mode(CompilationMode::CargoCheck))
.pattern_library("patterns.db")
.build()?;
// Compile and get structured feedback
let result = citl.compile(code)?;
match result {
CompilationResult::Success { .. } => println!("Success!"),
CompilationResult::Failure { errors, .. } => {
for error in errors {
println!("Error {}: {}", error.code, error.message);
}
}
}§References
- Wang, Y., et al. (2022). Compilable Neural Code Generation with Compiler Feedback. ACL.
- Yasunaga, M., & Liang, P. (2020). Graph-based Self-Supervised Program Repair. ICML.
- Dou, S., et al. (2024). StepCoder: Improve Code Generation with RLCF. arXiv.
Structs§
- CITL
- Main CITL orchestrator.
- CITL
Builder - Builder for CITL instances.
- CITL
Config - CITL configuration.
- Cargo
Project - Temporary Cargo project for compilation.
- Code
Replacement - Code replacement for a suggestion.
- Compilation
Metrics - Compilation metrics for analysis.
- Compilation
Time Metrics - Metrics for compilation times.
- Compile
Options - Compilation options.
- Compiled
Artifact - Compiled artifact information.
- Compiler
Diagnostic - Structured compiler diagnostic.
- Compiler
Suggestion - Compiler suggestion for fixing the error.
- Compiler
Version - Compiler version information.
- Contrastive
Loss InfoNCEcontrastive loss for learning embeddings.- Convergence
Metrics - Metrics for convergence (iterations to fix).
- Diagnostic
Label - Additional labeled span within a diagnostic.
- Error
Code - Error code with metadata for categorization and curriculum learning.
- Error
Embedding - Error embedding vector.
- Error
Encoder - Error encoder using simplified feature extraction.
- Error
FixPattern - Error-fix pattern learned from successful repairs.
- Error
Frequency Metrics - Metrics for error frequencies.
- FixAttempt
Metrics - Metrics for fix attempts.
- FixResult
- Result of an iterative fix attempt.
- FixTemplate
- Parameterized fix template.
- GNNError
Encoder - GNN-based error encoder using program-feedback graphs.
- Metrics
Summary - Summary of all metrics.
- Metrics
Tracker - Comprehensive metrics tracker for CITL operations.
- Neural
Encoder Config - Configuration for the neural encoder.
- Neural
Error Encoder - Neural error encoder using transformer architecture.
- Pattern
Library - Pattern library with similarity search.
- Pattern
Match - Pattern match result.
- Pattern
Usage Metrics - Metrics for pattern usage.
- Program
Feedback Graph - Program-feedback graph structure.
- Rust
Compiler - Rust compiler interface.
- Source
Span - Source code span for error location.
- Suggested
Fix - A suggested fix for a compiler error.
- Training
Sample - A training sample for the neural encoder.
- Triplet
Loss - Triplet Loss for metric learning with margin.
- Type
Info - Type information extracted from type errors.
- Vocabulary
- Vocabulary for tokenization.
Enums§
- CITL
Error - CITL-specific error type.
- Compilation
Mode - Compilation mode for Rust compiler.
- Compilation
Result - Structured compilation result.
- Diagnostic
Severity - Diagnostic severity level.
- Difficulty
- Difficulty level for curriculum learning.
- Edge
Type - Edge type in program-feedback graph.
- Error
Category - Error category for semantic grouping.
- Language
- Source language for transpiler adapters.
- Node
Type - Node type in program-feedback graph.
- Rust
Edition - Rust edition.
- Suggestion
Applicability - Suggestion applicability level.
- Triplet
Distance - Distance metric for triplet loss.
Statics§
- RUST_
ERROR_ CODES - Known Rust error codes with categories and difficulties.
Traits§
- Compiler
Interface - Universal compiler interface supporting any language toolchain.
Functions§
- rust_
error_ codes - Initialize the static error codes properly.
Type Aliases§
- CITL
Result - Convenience type alias for CITL Results.