AI-assisted Java method naming recommendation system using LLM and RAGFlow.
CodeNaming recommends Java/Spring-style method names from natural language descriptions by analyzing developer intent, retrieving relevant naming knowledge, and evaluating whether generated names preserve the original intent.
Developers often need to convert natural language requirements into clear and consistent method names.
Input
Find active members by email
Output
findActiveMemberByEmail
CodeNaming assists this process by combining:
- Intent Analysis
- LLM-based Candidate Generation
- RAGFlow Knowledge Retrieval
- Intent Preservation Evaluation
- Java Naming Convention Validation
- Caffeine-based Result Caching
The goal is to generate meaningful Java method names while preserving the semantic intention of the original description.
The final system uses a RAG-augmented Two-Call LLM Pipeline.
User Description
↓
RAGFlow Knowledge Retrieval
↓
Retrieved Knowledge Context
↓
Intent Analysis + Candidate Generation
↓
Intent Preservation Evaluation
↓
Final Method Name Recommendation
RAGFlow acts as a Knowledge Retrieval Layer.
It retrieves relevant knowledge from a prebuilt Dataset and provides the retrieved context to the LLM naming pipeline.
RAGFlow does not directly generate method names and does not automatically analyze the user's project source code.
The first implementation separated the naming process into three LLM calls.
User Description
↓
Intent Analysis
↓
Candidate Generation
↓
Intent Preservation Evaluation
↓
Final Recommendation
Characteristics:
- Clear separation of responsibilities
- Independent intent evaluation
- Higher LLM API usage
- Higher response latency
Benchmark experiments were used to compare pipeline alternatives.
The architecture was optimized by combining Intent Analysis and Candidate Generation into a single LLM call.
User Description
↓
Intent Analysis + Candidate Generation
↓
Intent Preservation Evaluation
↓
Final Recommendation
Improvements:
- Reduced LLM calls from 3 to 2
- Simplified pipeline structure
- Reduced response latency
- Reduced external API usage
- Preserved intent evaluation as an independent stage
After optimizing the LLM pipeline, RAGFlow was integrated as an additional Knowledge Retrieval Layer.
User Description
↓
RAGFlow Retrieval
↓
Dataset Knowledge Context
↓
Two-Call LLM Pipeline
↓
Final Recommendation
The retrieved context helps the naming pipeline make recommendations using additional naming-related knowledge instead of relying only on the user description and the LLM's internal knowledge.
The system analyzes a natural language description and extracts its naming intent.
Example:
Find active members by email
The intent can be represented using information such as:
Action:
FIND
Target:
Member
Qualifier:
Active
Condition:
Email
RAGFlow retrieves relevant knowledge from a prebuilt Dataset.
The Dataset contains knowledge such as:
- Code-related Knowledge
- Java/Spring Naming Knowledge
- Naming Patterns
The retrieved knowledge is used as additional context for Method Name Generation.
The first LLM call performs:
Intent Analysis
+
Candidate Generation
Using both the user description and retrieved knowledge context, the system generates Java-style Method Name candidates.
Example:
findActiveMemberByEmail
findActiveMembersByEmail
The second LLM call evaluates whether generated candidates preserve the original developer intent.
Evaluation focuses on:
- Semantic intent preservation
- Java Naming Convention
- Method purpose clarity
- Naming naturalness
The evaluation stage helps prevent method names that are syntactically valid but semantically inconsistent with the original requirement.
The system uses Caffeine as an in-memory cache for repeated requests.
When the same description is requested again, the cached result can be returned without repeating the full Retrieval and LLM Pipeline.
Current cache configuration:
Cache Name:
quickNaming
TTL:
10 minutes
Maximum Size:
100 entries
This reduces unnecessary external API calls and improves response time for repeated requests.
- Java 21
- Spring Boot
- Gradle
- Large Language Model API
- Prompt Engineering
- Structured Output
- Intent Preservation Evaluation
- RAGFlow
- Knowledge Retrieval
- Dataset-based Context Augmentation
- Caffeine Cache
- Benchmark-based Pipeline Optimization
- Latency Measurement
- Docker
- RAGFlow Local Deployment
- HTML
- CSS
- JavaScript
The project uses benchmark experiments to support architecture decisions instead of selecting pipeline structures only through subjective judgment.
| Architecture | LLM Calls |
|---|---|
| 3-Call Pipeline | 3 |
| Two-Call Pipeline | 2 |
Evaluation criteria included:
- Naming Quality
- Intent Preservation
- Response Latency
- API Call Efficiency
The benchmark results were used to select the Two-Call Pipeline as the final LLM architecture.
Retrieval approaches were also evaluated to examine the effect of adding external Knowledge Context to the naming pipeline.
The experiments include comparison results for lightweight/keyword-based retrieval and RAGFlow-based retrieval.
Evaluation focuses on:
- Retrieval behavior
- Naming Quality
- Response Latency
- Context utilization
Benchmark source code and result files are included in the repository.
The RAGFlow Dataset contains Java/Spring-related naming knowledge used by the Retrieval Layer.
Example Dataset entries include:
AuthService_generateToken
AuthService_validateToken
FileService_uploadFile
NotificationService_sendMessage
OrderService_updateStatus
PaymentService_processPayment
PaymentService_refund
ProductService_searchProduct
UserService_changePassword
UserService_createUser
UserService_findUser
UserService_registerUser
These files provide naming-related Knowledge Context that can be retrieved by RAGFlow.
CodeNaming_Project/
│
├── CodeNaming/
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ └── resources/
│ │ └── test/
│ │
│ ├── benchmark/
│ │ ├── BenchmarkRunner.java
│ │ ├── benchmark_dataset.csv
│ │ ├── result_keyword.csv
│ │ └── result_ragflow.csv
│ │
│ ├── docs/
│ ├── gradle/
│ ├── build.gradle
│ ├── settings.gradle
│ ├── gradlew
│ └── gradlew.bat
│
├── dataset/
│ └── RAGFlow knowledge dataset
│
├── experiments/
│ ├── pipeline-comparison/
│ └── retrieval-comparison/
│
├── docs/
│ ├── architecture/
│ └── design-history/
│
├── .env.example
├── .gitignore
└── README.md
The main backend implementation is organized as follows:
com.codenaming
│
├── component
│ ├── IntentCandidateGenerator
│ ├── IntentPreservationEvaluator
│ └── ...
│
├── config
│ ├── CacheConfig
│ └── LLM configurations
│
├── controller
│ └── QuickNamingController
│
├── dto
│
├── llm
│ ├── LlmClient
│ └── LLM client implementations
│
├── model
│
├── retrieval
│ ├── NamingKnowledgeRetriever
│ ├── KeywordNamingKnowledgeRetriever
│ │
│ └── ragflow
│ ├── RagFlowClient
│ ├── RagFlowNamingKnowledgeRetriever
│ ├── RagFlowProperties
│ └── RagFlowRetrievalConfig
│
├── schema
│
├── service
│ └── NamingService
│
└── validator
Sensitive API keys are not included in the repository.
Create a local .env file using .env.example as a reference.
ELEX_API_KEY=your_elex_api_key
RAGFLOW_API_KEY=your_ragflow_api_key
RAGFLOW_DATASET_ID=your_dataset_id
RAGFLOW_BASE_URL=http://localhost:9380
CODENAMING_RETRIEVAL_PROVIDER=ragflowThe actual .env file must not be committed to Git.
Install:
- Java 21
- Docker Desktop
- RAGFlow
Start the local RAGFlow Docker environment from the RAGFlow Docker directory:
docker compose up -dCheck container status:
docker compose psConfigure the required environment variables using your local .env values.
Required values include:
ELEX_API_KEY
RAGFLOW_API_KEY
RAGFLOW_DATASET_ID
RAGFLOW_BASE_URL
CODENAMING_RETRIEVAL_PROVIDER
Move to the Spring Boot project directory:
cd CodeNamingRun the application.
Windows
gradlew.bat bootRunmacOS / Linux
./gradlew bootRunAfter the application starts, open:
http://localhost:8080
Example request:
Find active members by email
Processing flow:
Natural Language Description
↓
RAGFlow Knowledge Retrieval
↓
Retrieved Knowledge Context
↓
Intent Analysis + Candidate Generation
↓
Intent Preservation Evaluation
↓
Method Name Recommendation
Example recommendation:
findActiveMemberByEmail
The final implementation includes:
- MVP Method Naming Recommendation System
- Initial 3-Call LLM Pipeline
- Benchmark-based Pipeline Comparison
- Optimized Two-Call LLM Pipeline
- Intent Preservation Evaluation
- Java Naming Convention Validation
- Lightweight / Keyword Knowledge Retrieval
- RAGFlow Knowledge Retrieval Integration
- Dataset-based Context Augmentation
- Retrieval Benchmark Experiment
- Caffeine In-memory Cache
- Spring Boot Web Application
- Automated Tests
CodeNaming was developed through iterative architecture design, benchmark evaluation, retrieval integration, and performance optimization to produce a completed AI-assisted Java Method Naming Recommendation System.