Skip to main content

Module citl

Module citl 

Source
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 backend
  • CompilerDiagnostic: Structured representation of compiler errors
  • ErrorEncoder: Encodes errors into embeddings for pattern matching
  • PatternLibrary: Stores learned error-fix patterns with HNSW index
  • FixGenerator: 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.
CITLBuilder
Builder for CITL instances.
CITLConfig
CITL configuration.
CargoProject
Temporary Cargo project for compilation.
CodeReplacement
Code replacement for a suggestion.
CompilationMetrics
Compilation metrics for analysis.
CompilationTimeMetrics
Metrics for compilation times.
CompileOptions
Compilation options.
CompiledArtifact
Compiled artifact information.
CompilerDiagnostic
Structured compiler diagnostic.
CompilerSuggestion
Compiler suggestion for fixing the error.
CompilerVersion
Compiler version information.
ContrastiveLoss
InfoNCE contrastive loss for learning embeddings.
ConvergenceMetrics
Metrics for convergence (iterations to fix).
DiagnosticLabel
Additional labeled span within a diagnostic.
ErrorCode
Error code with metadata for categorization and curriculum learning.
ErrorEmbedding
Error embedding vector.
ErrorEncoder
Error encoder using simplified feature extraction.
ErrorFixPattern
Error-fix pattern learned from successful repairs.
ErrorFrequencyMetrics
Metrics for error frequencies.
FixAttemptMetrics
Metrics for fix attempts.
FixResult
Result of an iterative fix attempt.
FixTemplate
Parameterized fix template.
GNNErrorEncoder
GNN-based error encoder using program-feedback graphs.
MetricsSummary
Summary of all metrics.
MetricsTracker
Comprehensive metrics tracker for CITL operations.
NeuralEncoderConfig
Configuration for the neural encoder.
NeuralErrorEncoder
Neural error encoder using transformer architecture.
PatternLibrary
Pattern library with similarity search.
PatternMatch
Pattern match result.
PatternUsageMetrics
Metrics for pattern usage.
ProgramFeedbackGraph
Program-feedback graph structure.
RustCompiler
Rust compiler interface.
SourceSpan
Source code span for error location.
SuggestedFix
A suggested fix for a compiler error.
TrainingSample
A training sample for the neural encoder.
TripletLoss
Triplet Loss for metric learning with margin.
TypeInfo
Type information extracted from type errors.
Vocabulary
Vocabulary for tokenization.

Enums§

CITLError
CITL-specific error type.
CompilationMode
Compilation mode for Rust compiler.
CompilationResult
Structured compilation result.
DiagnosticSeverity
Diagnostic severity level.
Difficulty
Difficulty level for curriculum learning.
EdgeType
Edge type in program-feedback graph.
ErrorCategory
Error category for semantic grouping.
Language
Source language for transpiler adapters.
NodeType
Node type in program-feedback graph.
RustEdition
Rust edition.
SuggestionApplicability
Suggestion applicability level.
TripletDistance
Distance metric for triplet loss.

Statics§

RUST_ERROR_CODES
Known Rust error codes with categories and difficulties.

Traits§

CompilerInterface
Universal compiler interface supporting any language toolchain.

Functions§

rust_error_codes
Initialize the static error codes properly.

Type Aliases§

CITLResult
Convenience type alias for CITL Results.