Forem

Cover image for Prompt Engineering For AI Model
Taki (Kieu Dang)
Taki (Kieu Dang)

Posted on

Prompt Engineering For AI Model

Prompt engineering in 2025 has evolved significantly, with each AI model—OpenAI’s ChatGPT, DeepSeek, Google Gemini, and GitHub Copilot—having distinct strengths and weaknesses. To develop expertise in prompt engineering across these models, it’s essential to understand their underlying architectures, capabilities, and ideal prompting techniques.


🔹 Background of Prompt Engineering in 2025

Prompt engineering is now a critical skill for AI engineers, full-stack developers, and software testers. The goal is to craft precise, structured prompts to maximize the performance of AI models. The skill is widely used in:

AI-powered development (code generation, debugging, refactoring)

Test automation (test case generation, test data creation)

Productivity tools (summarization, document processing, domain-specific knowledge retrieval)

Chatbots and Virtual Assistants (user interaction, personalization, dynamic response generation)

Each AI model responds differently to prompts due to variations in training data, fine-tuning, and API behavior.


🔹 Prompt Engineering for Different AI Models

1️⃣ OpenAI (ChatGPT 4 & 5, GPT-4-turbo)

🛠 Best Use Cases:

  • Natural language understanding & generation
  • Code explanation & debugging
  • Test case generation
  • Chatbots & virtual assistants

📝 Prompting Techniques:

Chain of Thought (CoT) Prompting → Improve reasoning by breaking down steps.

Few-shot Learning → Provide examples before the query to guide the model.

Role-based Prompting → Assign a persona to the AI (e.g., "You are a senior SDET...").

System Instructions → Use "system" messages in API calls to define behavior consistently.

Temperature & Top-p Control → Adjust creativity and randomness for different use cases.

📌 Example:

"You are an expert software tester specializing in automation. Given the following requirement, generate detailed test cases with preconditions, steps, and expected results."

Test Generation
💡 Use Case: Generate test cases from a product specification.

🔹 Prompt:

You are an expert software tester specializing in automation.  
Given the following feature specification, generate detailed test cases, including:  
- Title  
- Preconditions  
- Steps  
- Expected Results  

### Feature Specification:  
A user should be able to reset their password by entering their registered email. The system should send a reset link to the email. The link expires in 15 minutes.  
Enter fullscreen mode Exit fullscreen mode

🔹 Expected Output:

Test Case 1: Verify password reset link is sent to the registered email  

**Preconditions:**  
- User has a registered account.  
- User is on the login page.  

**Steps:**  
1. Click on "Forgot Password".  
2. Enter the registered email address.  
3. Click "Submit".  

**Expected Results:**  
- The system displays a success message.  
- The registered email receives a password reset link.  
- The link expires after 15 minutes.  
Enter fullscreen mode Exit fullscreen mode

ChatGPT is great for structured outputs like test cases and documentation.

🔹 Best Practices Applied:

Edge Cases Covered (Expiration, retries, brute-force attacks)

Security Risks Considered (Brute-force & replay attacks)

Structured Format for Test Case Documentation


2️⃣ DeepSeek (DeepSeek-VL & DeepSeek Coder)

🛠 Best Use Cases:

  • Multimodal AI (text + image processing)
  • Code generation & refactoring
  • Mathematical problem solving

📝 Prompting Techniques:

Zero-shot Prompting → Works well even without examples.

Code-first Approach → Structure prompts in a way that encourages direct coding.

Task Segmentation → Ask DeepSeek to break a complex task into subtasks.

📌 Example:

"Generate a unit test in NestJS for a service that retrieves user data from MongoDB. Use Jest and ensure edge cases are covered."

Code Generation
💡 Use Case: Generate a NestJS unit test for a MongoDB service.

🔹 Prompt:

You are a senior backend developer. Generate a unit test in NestJS using Jest for a service that retrieves user data from MongoDB.  
Ensure the test covers:  
- Valid user retrieval  
- Non-existent user handling  
- Error scenarios  
Enter fullscreen mode Exit fullscreen mode

🔹 Expected Output (DeepSeek Coder):

import { Test, TestingModule } from '@nestjs/testing';
import { UserService } from './user.service';
import { getModelToken } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import { User } from './user.schema';

describe('UserService', () => {
  let service: UserService;
  let model: Model<User>;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        UserService,
        {
          provide: getModelToken('User'),
          useValue: {
            findOne: jest.fn(),
          },
        },
      ],
    }).compile();

    service = module.get<UserService>(UserService);
    model = module.get<Model<User>>(getModelToken('User'));
  });

  it('should return a user when found', async () => {
    const mockUser = { email: 'test@example.com', name: 'Test User' };
    jest.spyOn(model, 'findOne').mockResolvedValue(mockUser);

    const result = await service.getUserByEmail('test@example.com');
    expect(result).toEqual(mockUser);
  });

  it('should return null when user is not found', async () => {
    jest.spyOn(model, 'findOne').mockResolvedValue(null);

    const result = await service.getUserByEmail('notfound@example.com');
    expect(result).toBeNull();
  });
});
Enter fullscreen mode Exit fullscreen mode

DeepSeek Coder performs well in structured code generation with real-world testing scenarios.


3️⃣ Google Gemini 1.5 (Previously Bard)

🛠 Best Use Cases:

  • Data analysis & visualization
  • Multimodal search (images + text)
  • Creative writing & research

📝 Prompting Techniques:

Hybrid Prompting → Mix structured instructions with open-ended prompts.

Fact-checking Prompting → Ask it to validate its responses with sources.

Context-Expanded Prompts → Use longer prompts with detailed context for better accuracy.

📌 Example:

"Summarize the latest trends in AI-driven test case generation, focusing on tools using RAG and LLM fine-tuning. Provide a comparison of Gemini and GPT for this task."

AI Research & Summarization

💡 Use Case: Summarize the latest AI-driven test case generation trends.

🔹 Prompt:

Summarize the latest trends in AI-driven test case generation, focusing on:  
1. RAG (Retrieval-Augmented Generation)  
2. LLM fine-tuning for software testing  
3. Differences between OpenAI’s GPT-4-Turbo and Gemini for test generation  
Provide references where possible.  
Enter fullscreen mode Exit fullscreen mode

🔹 Expected Output (Gemini 1.5):

### AI-Driven Test Case Generation Trends (2025)  

1️⃣ **Retrieval-Augmented Generation (RAG)**  
- AI models now retrieve domain-specific test cases from vector databases (e.g., MongoDB Vector Search).  
- RAG reduces hallucinations and improves context-aware test cases.  

2️⃣ **LLM Fine-Tuning for Software Testing**  
- Companies fine-tune models using their historical test cases.  
- Open-source fine-tuning frameworks like LoRA and QLoRA make it efficient.  

3️⃣ **GPT-4-Turbo vs. Gemini**  
- GPT-4-Turbo performs better in structured outputs.  
- Gemini 1.5 has stronger multimodal understanding (text + images).  
Enter fullscreen mode Exit fullscreen mode

Gemini is great for summarization and AI research-driven tasks.


4️⃣ GitHub Copilot (GPT-4-Turbo for Code)

🛠 Best Use Cases:

  • Real-time code completion
  • Code optimization & best practices
  • Pair programming assistance

📝 Prompting Techniques:

Inline Comment Prompting → Use structured comments to guide code completion.

Function Signature Completion → Start writing the function definition and let Copilot infer the logic.

Iterative Prompting → Refine suggestions by interacting with the model.

📌 Example:

// Create a NestJS controller that handles CRUD operations for users
// Use dependency injection for the service
Enter fullscreen mode Exit fullscreen mode

Code Completion
💡 Use Case: Real-time NestJS CRUD API generation with Copilot.

🔹 Prompt (Inline Comment in VS Code):

// Create a NestJS service that handles CRUD operations for a "Product" entity
// Use dependency injection for MongoDB
Enter fullscreen mode Exit fullscreen mode

🔹 Copilot Completion (Expected Output):

import { Injectable } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import { Product, ProductDocument } from './product.schema';

@Injectable()
export class ProductService {
  constructor(@InjectModel(Product.name) private productModel: Model<ProductDocument>) {}

  async create(productDto: any): Promise<Product> {
    const newProduct = new this.productModel(productDto);
    return newProduct.save();
  }

  async findAll(): Promise<Product[]> {
    return this.productModel.find().exec();
  }

  async findOne(id: string): Promise<Product | null> {
    return this.productModel.findById(id).exec();
  }

  async update(id: string, productDto: any): Promise<Product | null> {
    return this.productModel.findByIdAndUpdate(id, productDto, { new: true }).exec();
  }

  async delete(id: string): Promise<void> {
    await this.productModel.findByIdAndDelete(id).exec();
  }
}
Enter fullscreen mode Exit fullscreen mode

Copilot excels at completing real-world production code by following developer intent.


🔹 Key Takeaways for 2025

Model Selection Matters → Choose the right AI based on the use case.

Prompt Structure is Critical → Format prompts properly for maximum efficiency.

Iterative Approach is Best → Keep refining prompts based on output.

Domain-Specific Fine-Tuning → Customize prompts for testing, development, or product-specific workflows.

Top comments (2)

Collapse
 
choovy profile image
Choovy

Good point !!

Collapse
 
sun_shade_b1b89171f4da101 profile image
Sun Shade

"Great article! As tech teams grow, managing HR efficiently becomes just as important as scaling infrastructure. At UpdateHR, we help companies streamline HR processes so developers can focus on building great products. Looking forward to more insightful content from the Dev community!"