Affichage des articles dont le libellé est Artificial intelligence. Afficher tous les articles
Affichage des articles dont le libellé est Artificial intelligence. Afficher tous les articles

Agent in AI

Agent in AI

Agent in AI

An agent in AI is a system that observes its environment, makes decisions, and takes actions. It follows a cycle that connects perception with action. Its goal is to achieve a target defined by its designer.

Core Idea

The agent senses the environment, processes the information, and selects the best action. It repeats this loop to improve behavior.

Main Components

1. Environment

The world where the agent operates. It provides inputs and reacts to actions.

2. Sensors

Tools that let the agent read the environment. For software agents, sensors can be text, data, or system states.

3. Actuators

Tools that allow the agent to take actions. For software agents, actuators can be outputs, messages, or API calls.

4. Policy

A rule that guides the agent. It determines actions for each state.

How an AI Agent Works

  • Observe the current state.
  • Process information.
  • Select an action based on the policy.
  • Execute the action.
  • Receive feedback or new state.

Types of AI Agents

1. Simple Reflex Agents

React to the current state. No memory.

2. Model Based Agents

Use internal state to track the environment.

3. Goal Based Agents

Choose actions that help reach a target.

4. Utility Based Agents

Evaluate outcomes and pick actions with high utility.

5. Learning Agents

Improve behavior through experience.

Where AI Agents Are Used

  • Recommendation systems
  • Autonomous vehicles
  • Game characters
  • Automation tools
  • Business decision systems

Strengths of AI Agents

  • Adaptive behavior
  • Continuous interaction
  • Support complex tasks

Limitations

  • Depend on quality of environment signals
  • Need strong policies
  • Hard tasks require advanced models

Agent in Moroccan Darija

Agent f AI huwa nizaam kaychouf environment, kayfker, w kaydir action. Kay3awd had loop bash ywasal goal.

Components

  • Environment. Dunia li kaykhdem fiha agent.
  • Sensors. Kayjma3o info.
  • Actuators. Kaydir actions.
  • Policy. Qanoun dyal choices.

Kif Kaykhddam

  • Kaychouf state.
  • Kay7seb shno ydir.
  • Kaydir action.
  • Kayakhod feedback.

Types

  • Simple reflex.
  • Model based.
  • Goal based.
  • Utility based.
  • Learning agent.

Conclusion

An AI agent observes, decides, and acts. It follows a loop that links environment signals with actions. Agents support many real systems in AI and automation.

Mixture of Experts in AI

Mixture of Experts in AI

Mixture of Experts in AI

Mixture of Experts is a model design that uses several expert networks. Each expert handles part of the input. A gating network decides which expert should process each token or sample. This improves scale and efficiency.

Core Idea

Instead of one large model, MoE uses many experts. Only some experts activate for each input. This reduces compute while keeping model capacity high.

How Mixture of Experts Works

  • The model receives an input.
  • The gating network scores experts.
  • The model selects a few experts with high scores.
  • The input passes through selected experts.
  • The outputs combine into one final result.

Key Components

1. Experts

Each expert is a small neural network. Experts learn different patterns. They specialize during training.

2. Gating Network

The gate chooses which experts to activate. It uses softmax or top k routing.

3. Router

The router directs tokens to experts. Good routing improves quality and efficiency.

Why MoE Models Help

  • Increase capacity without increasing compute for each token
  • Improve specialization between experts
  • Scale to large tasks

Popular MoE Approaches

Switch Transformer

Uses one expert per token. Routing stays simple and fast.

GShard

Uses distributed experts across devices. Supports large scale training.

Sparse MoE Layers

Only some experts activate. This keeps training efficient.

Challenges

  • Balancing load across experts
  • Training stability
  • Routing complexity

Use Cases

  • Large language models
  • Multimodal systems
  • Machine translation
  • Vision language tasks

Mixture of Experts in Moroccan Darija

Mixture of Experts howa model li kayst3mel bzzaf dial experts. Kul expert kayt3llam pattern mokhtalef. Gating network kaykhtar shkon khaso ykhddm m3a input.

Kif Kaykhddam

  • Input kaydkhl.
  • Gate kaydir scoring.
  • Model kaykhtar experts b scoring kbir.
  • Experts kay3aljo input.
  • Outputs kaysslafo f result wahd.

Mfad

  • Capacity kbar b compute sghir.
  • Specialization dial experts.
  • Scale mzyan.

Moshkilat

  • Load balancing.
  • Training stability.
  • Routing.

Conclusion

Mixture of Experts increases model capacity with efficient compute. It uses routing and specialized experts to produce strong results in modern AI.

Prompt Engineering in AI

Prompt Engineering in AI

Prompt Engineering

Introduction

Prompt engineering is the practice of writing clear instructions for large language models. Good prompts guide the model and improve accuracy. Strong prompts reduce errors and increase control. In this guide you learn core ideas, useful formats, and practical examples.

Prompt engineering هو فن كتابة talimat واضحة باش AI يعطيك output مزيان. Prompt واضح كيسهل الفهم و كيحسن الجودة.

Core Concepts Explained

Large language models depend on the text you give them. Clear intent, context, and structure help the model produce stable results. Prompts act like instructions that shape the full answer.

LLM كيتبع prompt بالحرف. إيلا كان prompt منظم، النتيجة كتكون دقيقة.

Core Principles

1. Clarity

Use short and direct text. Remove extra words. Tell the model exactly what you want.

2. Context

Add the background needed to understand the task. This reduces confusion.

3. Constraints

Define format, tone, or length. These limits guide the output.

4. Examples

Show sample inputs and outputs. This builds a pattern the model follows.

Common Prompt Types

Instruction Prompts

Give direct commands such as “Write a summary” or “Translate this text”.

Question Prompts

Ask a clear question to get a focused answer.

Role Prompts

Assign a role to the model like “act as a tutor”.

Few Shot Prompts

Provide examples that teach the model how to respond.

Useful Techniques

1. Step by Step Reasoning

Tell the model to break the reasoning into steps. This improves logic and clarity.

2. Structured Output

Ask for lists, tables, or sections. Structure improves readability.

3. Style Control

Specify tone like “short and direct” or “technical explanation”.

4. Iterative Prompting

Refine your prompt after checking the output. This builds stronger instructions.

Practical Examples

1. Instruction Prompt

Explain neural networks in three short points.

2. Role Prompt

You are an AI tutor. Teach activation functions in simple steps.

3. Few Shot Prompt


Input: "The product is great"
Output: Positive

Input: "The service was slow"
Output: Negative

Input: "I enjoyed the design"
Output:

4. Structured Prompt


Give a summary using this format:
- Definition
- Key points
- Small example

Common Mistakes

  • Vague instructions
  • Missing context
  • Too many requirements
  • Unclear formatting

Prompt Engineering in LLM Tasks

  • Code generation
  • Editing and rewriting
  • Data extraction
  • Summarization
  • Reasoning tasks

Prompt Engineering in Moroccan Darija

Prompt engineering يعني تكتب talimat واضحة باش AI يفهم المطلوب بلا ضبابية. Context مهم. Constraints مهمين. Examples كيعلمو AI النمط لي خاصو يتبع.

Nqta Asasiya

  • Koun wadeh f talab
  • Zid context kifach خصو يجاوب
  • Hdoud format bach output يكون منظم
  • Examples كيسهلو الخدمة

Types Dial Prompts

  • Instructions
  • Questions
  • Roles
  • Few shot

Syntax or Structure Example

This example shows how to structure a prompt for an AI model.


Task: Explain ReLU in simple steps
Context: Beginner student
Format: 3 points only
Style: Clear and short

Answer:

Exercises

  • Write an instruction prompt for explaining CNNs.
  • Create a role prompt where the model acts as a data science tutor.
  • Write a few shot prompt for sentiment labels.
  • Give a structured prompt for describing activation functions.
  • Rewrite a vague prompt into a clear one.
  • Write a prompt that asks for step by step reasoning.
  • Design a prompt that includes constraints on length.
  • Create a prompt for extracting keywords from text.
  • Write an iterative improvement prompt.
  • Build a prompt that includes one example and one instruction.

Internal Linking Suggestions

[internal link: Machine Learning Basics]

[internal link: NLP and LLM Guide]

Conclusion

Prompt engineering helps you control AI behavior. Clear prompts produce strong results. With practice you design prompts that stay accurate and stable.

Prompt engineering كيعطيك تحكم ف output. كلما كان prompt منظم، كل

Agents vs Agentic in AI

Agents vs Agentic in AI

Introduction

This guide explains the difference between AI agents and agentic AI. The goal is simple understanding. Next, you follow clear definitions, workflows, and examples.

هاد الشرح كيبين الفرق بين agent و agentic AI بطريقة واضحة. غادي تشوف التعريف، الاستعمال، و workflow ديال كل واحد.

Core Concepts Explained

An AI agent runs a short loop of sensing, processing, and acting. Agentic AI runs a long loop with planning, feedback, and correction. The second one focuses on goals, not single actions.

الـ agent كيخدم خطوة بسيطة. الـ agentic AI كيخدم process كامل فيه planning و feedback.

What Is an AI Agent

An AI agent is a program that takes input from an environment and returns an action. The pattern stays fixed and simple.

  • Sense the environment
  • Process the input
  • Return an action

AI agents handle single tasks. They follow instructions without extended reasoning.

Examples of Simple Agents

  • Chatbots with fixed rules
  • Recommendation engines
  • Basic automation scripts

What Is Agentic AI

Agentic AI goes beyond simple reactions. It understands goals. It builds plans. It breaks goals into tasks. It observes results and corrects the next step.

Agentic AI uses reasoning loops. It adapts when errors appear.

Key Features of Agentic AI

  • Goal driven behavior
  • Planning and task decomposition
  • Feedback loops
  • Autonomous execution
  • Self correction

Main Differences

Aspect AI Agent Agentic AI
Purpose Single task Goal with multiple tasks
Reasoning Limited Planning and reflection
Autonomy Low High
Adaptation Low Ongoing correction
Workflow One loop Multi step chain

Simple Flow of Each System

Agent Flow

  • Input
  • Process
  • Action

Agentic AI Flow

  • Understand goal
  • Plan tasks
  • Execute steps
  • Review output
  • Fix errors
  • Reach result

Where They Are Used

AI Agents

  • Customer support bots
  • Email sorting tools
  • Simple automation systems

Agentic AI

  • Research assistants
  • Code generation workflows
  • Business automation chains
  • Multi step data processing

Agents vs Agentic in Moroccan Darija

ف AI، كاين فرق كبير بين agent و agentic system. الـ agent كيخدم step wahda. الـ agentic AI كيخدم workflow كامل فيه planning و feedback و correction.

Shno Howa Agent

  • Kaydkhl input
  • Kay7seb
  • Kaydir action wahda

Shno Howa Agentic AI

  • Kayfhem l goal
  • Kaykhtat tasks
  • Kaydir steps m3a feedback
  • Kayss7 l errors

Far9 Sarih

  • Agent simple
  • Agentic kayplanning
  • Agent kay7der step wahda
  • Agentic kay7der workflow kamel

Syntax or Model Structure Example

Below is a small Python example showing a very simple agent vs a simple agentic loop.

# Simple agent
def agent(input_data):
    if input_data == "spam":
        return "Filter"
    return "Allow"

print(agent("spam"))

# Simple agentic loop
def agentic(goal):
    steps = ["plan", "execute", "review", "fix"]
    log = []
    for step in steps:
        log.append(f"{step} for {goal}")
    return log

print(agentic("analyze report"))

مثال بسيط يبين الفرق بين agent و agentic workflow.

Exercises

  • Write a one sentence definition of an AI agent.
  • List three features of agentic AI.
  • Explain why an agentic system needs feedback loops.
  • Create a three step plan for an agentic system that organizes files.
  • Write a Python function that simulates a simple agent.
  • Modify the example code to add a new step in the agentic loop.
  • List cases where agents work well.
  • List cases where agentic AI works better.
  • Describe one risk of using agentic AI in complex workflows.
  • Design a small agentic workflow for data cleaning.

Conclusion

AI agents react. Agentic AI plans. The difference shapes modern AI systems. Working with both helps you understand classic and modern AI behavior.

ال agent كيخدم responses بسيطة. الـ agentic AI كيخطط و كيصلح. وهنا كيبان التطور الكبير ف AI.

Introduction to Expert Systems

Introduction to Expert Systems

Introduction

Expert systems represent early symbolic AI. They use rules and facts to solve domain problems. The logic stays strict. The workflow stays predictable. Next, you discover the core elements and how these systems work.

الـ expert systems هما أنظمة كتخدم ب rules و facts باش تعطي حلول واضحة ف مجالات محددة. الخدمة ديالها منضبطة و مبنية على logic.

Core Concepts Explained

An expert system imitates how a domain expert thinks. It works with symbolic rules instead of statistical learning. The system checks conditions, applies rules, then produces a conclusion.

الـ expert system كيقلد طريقة التفكير ديال expert ف واحد المجال. كيستعمل قواعد منطقية و ماشي models تدريبية.

Main Components

1. Knowledge Base

The knowledge base stores rules and facts. Rules define decisions. Facts describe the domain.

2. Inference Engine

The inference engine reads rules. It checks conditions. It triggers matching rules. It moves step by step to final results.

3. User Interface

This interface lets the user enter data and read answers. It acts as the connection between the user and the system.

4. Explanation Module

This module shows which rules fired. It explains why the system reached the final result.

5. Knowledge Acquisition Module

This module helps experts add new rules without breaking the system. It builds the knowledge base safely.

ف الـ Darija:

  • Knowledge base كتجمع rules و facts.
  • Inference engine كيطلق القواعد و كيوصل للنتيجة.
  • Interface كيدخل user معلومات و كيعطيه الجواب.
  • Explanation كتوضح المسار.
  • Knowledge acquisition كتساعد باش نزادو قواعد جديدة.

How Expert Systems Work

The workflow stays simple.

  • User enters input
  • System checks rules
  • Inference engine selects matching rules
  • Engine triggers rules
  • System outputs the final answer

الطريقة: user كيدخل data، system كيقلب على rules لي كتنطبق، و النتيجة كتخرج مباشرة.

Inference Types

Forward Chaining

Starts from known facts and moves forward until reaching a conclusion.

Backward Chaining

Starts from a goal and searches for facts that support it.

ف الـ Darija:

  • Forward chaining كيبدا من facts.
  • Backward chaining كيبدا من goal.

Examples of Expert Systems

  • Medical diagnosis tools
  • Financial decision support
  • Fault detection systems
  • Legal reasoning tools

أمثلة: diagnosis، finance، fault detection.

Syntax or Model Structure Example

Below is a simple Python example that simulates a tiny rule-based expert system.

facts = {"fever": True, "cough": True}

rules = [
    {"if": ["fever", "cough"], "then": "flu"},
    {"if": ["fever"], "then": "possible infection"}
]

def infer(facts, rules):
    conclusions = []
    for rule in rules:
        if all(fact in facts and facts[fact] for fact in rule["if"]):
            conclusions.append(rule["then"])
    return conclusions

result = infer(facts, rules)
print(result)

هادا مثال بسيط كيبين كيفاش rules كتعطي conclusion بناءً على facts.

Strengths

  • Consistent decisions
  • Readable rules
  • Strong performance in narrow domains
  • Low cost after setup

Limitations

  • Hard to update
  • No learning ability
  • Weak performance outside the domain

Exercises

  • Define an expert system in one simple sentence.
  • List three components of an expert system.
  • Create a rule that detects a simple condition.
  • Write a small Python dictionary that represents facts.
  • Explain the difference between forward and backward chaining.
  • Add one new rule to the example code.
  • Build a mini knowledge base with five rules.
  • Explain why expert systems do not learn.
  • Describe one domain that benefits from expert systems.
  • Design a simple workflow for a rule-based medical assistant.

Conclusion

Expert systems remain useful for structured rule-based tasks. They follow logic, give stable answers, and offer readable reasoning. They form an important part of symbolic AI.

الـ expert systems مفيدين ف المهام لي فيها قواعد ثابتة. الخدمة ديالهم واضحة و النتايج مفهومة.