Generative AI Engineer (Part 2) — Interview 1¶
Q: Who decides user access levels when using MCP servers and applications?
- User access levels and permissions within the MCP server ecosystem are centrally managed through [Company]’s enterprise authentication and authorization framework.
- The [Company] Identity Provider ([Company] IdP) is responsible for authenticating users and issuing JWT tokens that encode user roles, groups, and permissions.
- Access control policies are defined and enforced at the authentication layer, leveraging role-based access control (RBAC) and integration with [Company]’s Active Directory/LDAP.
- Application owners, IT administrators, and compliance officers collaborate to define which roles or user groups have access to specific APIs, tools, or data resources exposed by MCP servers.
- The MCP server validates each incoming request’s JWT token, checks the user’s roles/permissions, and authorizes or denies access accordingly.
- This ensures that only authorized users can access specific resources, and all access is logged for audit and compliance purposes.
- In summary, access decisions are governed by enterprise security policies, managed centrally via [Company] IdP, and enforced programmatically by the MCP server at runtime.
Q: Can you elaborate on the fine-tuning process in your second project, including which model you fine-tuned and the resources used?
- In the Universal Intent Determination System (UIDS) project, we explored fine-tuning multiple models to optimize intent classification across multilingual customer support channels.
- The main production model was SetFit, chosen for its efficiency and strong multilingual support, but we also experimented with fine-tuning larger transformer models like Falcon-7B and Falcon-40B for benchmarking and specialized use cases.
Fine-Tuning Process:
- Model Selection:
- SetFit (Sentence Transformers with a classification head) was the primary model due to its few-shot learning capability and support for 50+ languages.
-
For advanced experimentation, we fine-tuned Falcon-7B using QLoRA-like techniques (parameter-efficient fine-tuning with PEFT and bitsandbytes).
-
Data Preparation:
- Datasets were ingested from enterprise sources, cleaned, and split into train/test sets.
-
Label encoding was performed and stored alongside the model artifacts.
-
Training Pipeline:
- Training was orchestrated using AWS SageMaker, leveraging HuggingFace Estimators for scalable, managed training jobs.
- Hyperparameters (epochs, batch size, learning rates, etc.) were configured via environment variables and YAML configs.
- For SetFit, the pipeline included loading pre-trained sentence transformers, attaching a classification head, and training on labeled intent data.
-
For Falcon-7B, fine-tuning was performed using PEFT and bitsandbytes for memory efficiency, with training scripts adapted for large-scale distributed training.
-
Resource Utilization:
- SetFit training was performed on standard GPU instances (e.g., ml.g4dn.xlarge or similar) due to its lightweight nature.
- Falcon-7B fine-tuning required high-memory GPU instances (e.g., ml.p4d.24xlarge) to handle the model size and batch processing.
-
Spot instances were used where possible to optimize costs, with checkpointing and max run/wait times configured for reliability.
-
Model Saving & Deployment:
- Fine-tuned models and label encoders were saved to S3 and registered for inference.
-
Real-time inference endpoints were deployed using SageMaker, supporting high-throughput production traffic (~250 TPS).
-
Monitoring & Evaluation:
- Automated evaluation pipelines generated classification reports, confidence scores, and tracked model performance.
- Experiment tracking was managed with MLFlow for reproducibility and comparison.
Summary: - We fine-tuned both SetFit and Falcon-7B models, using AWS SageMaker for scalable training and deployment. SetFit was used in production for its efficiency and multilingual support, while Falcon-7B was fine-tuned for advanced experimentation, leveraging high-memory GPU resources and parameter-efficient techniques. All training, evaluation, and deployment steps were automated and monitored for robust, enterprise-grade AI delivery.
Q: Explain how ChatGPT works end-to-end when a user submits a query.
- When a user submits a query to ChatGPT, several key steps occur in the backend to generate a relevant, coherent response. Here’s a practical, industry-focused breakdown:
1. User Input Reception - The user enters a prompt (question or statement) via a frontend interface (web, API, app). - The input is sent to the backend server hosting the ChatGPT model.
2. Preprocessing - The backend processes the input: tokenizes the text (converts words into numerical tokens using a tokenizer compatible with the model, e.g., GPT-3/4 tokenizer). - Additional context (like conversation history) may be appended to maintain dialogue continuity.
3. Model Inference - The tokenized input is fed into the pre-trained transformer-based language model (e.g., GPT-3.5, GPT-4). - The model uses its deep neural network (with billions of parameters) to predict the next tokens in the sequence, generating a response token by token. - The model leverages its training on vast datasets to understand context, intent, and generate human-like text.
4. Postprocessing - The generated tokens are decoded back into human-readable text. - Optional: The response may be filtered for safety, compliance, or to remove inappropriate content.
5. Response Delivery - The final response is sent back to the user interface for display.
6. (Optional) Logging & Analytics - The interaction may be logged for monitoring, analytics, or further model improvement.
Industry Example (from Knowledge GPT API Architecture): - In enterprise setups, the process may include additional steps: - Intent detection (using a separate intent classification API). - Retrieval-Augmented Generation (RAG): The model may first retrieve relevant documents from a knowledge base (using semantic search with OpenSearch or Elasticsearch), then use those documents as context for the LLM to generate a more accurate, grounded response. - Citations and references are extracted and included in the response for transparency.
Summary: - ChatGPT works by receiving user input, preprocessing it, running it through a large language model to generate a response, postprocessing the output, and delivering it back to the user. In enterprise or advanced use cases, additional layers like intent detection, document retrieval, and response enrichment may be integrated for more accurate and context-aware answers.
Q: What is the meaning of GPT?
- GPT stands for Generative Pre-trained Transformer.
- Generative: The model can generate new, coherent text based on the input it receives.
- Pre-trained: The model is first trained on a large corpus of text data in an unsupervised way, learning language patterns, grammar, and knowledge before any task-specific fine-tuning.
- Transformer: Refers to the underlying neural network architecture, which uses self-attention mechanisms to process and understand the relationships between words in a sequence efficiently.
- In summary, GPT is a type of AI language model that generates human-like text by leveraging a transformer architecture that has been pre-trained on massive datasets.
Q: In ChatGPT, does both encoding and decoding happen, or is it just decoding?
- In ChatGPT (and GPT models in general), only the decoding process happens during inference (when generating responses).
- GPT models are based on the decoder-only transformer architecture:
- The input text is tokenized and passed through multiple transformer decoder layers.
- The model predicts the next token in the sequence, one token at a time, using only the decoder stack.
- There is no separate encoder as found in encoder-decoder models like BERT or T5.
- The model uses self-attention within the decoder to understand context and generate coherent text.
- So, during response generation, it’s just the decoding process that is active—encoding and decoding as separate stages do not occur in GPT.
Summary: In ChatGPT, only decoding happens; the model architecture is decoder-only, and there is no separate encoding stage as in encoder-decoder models.
Q: Is converting user text into numbers considered encoding in ChatGPT?
- Yes, converting user text into numbers is technically called tokenization or input encoding.
- When you submit a query, the text is tokenized—each word or subword is mapped to a unique numerical token ID.
- This process is necessary for the model to process and understand the input.
- However, in the context of the GPT architecture, the term "encoder" usually refers to a dedicated encoder block (as in encoder-decoder models like BERT or T5).
- GPT models are decoder-only transformers, meaning all the main neural network layers are part of the decoder stack.
- The initial step of converting text to tokens is a preprocessing step, not the same as having a separate encoder network.
- So, while there is an "encoding" step (tokenization), the model itself only uses the decoder stack for processing and generating responses.
Summary: Converting text to numbers is called tokenization or input encoding, but in GPT models, there is no separate encoder block—only the decoder stack processes the input tokens.
Q: In ChatGPT, does encoding happen at all, or is it only decoding?
- Yes, encoding does happen in ChatGPT, but it’s important to distinguish between two meanings of "encoding":
- Tokenization/Input Encoding:
- When you submit a query, your text is converted into numerical tokens using a tokenizer.
- This is a necessary preprocessing step so the model can process the input.
- Encoder Block (in Model Architecture):
- In transformer models, "encoder" usually refers to a dedicated neural network block (as in BERT or T5).
- GPT/ChatGPT does NOT have a separate encoder block—it uses a decoder-only transformer architecture.
- Process in ChatGPT:
- User text → tokenization (input encoding) → tokens processed by decoder layers → output tokens → detokenization (output decoding) → human-readable text.
- So, while there is an "encoding" step (tokenization), the model itself only uses the decoder stack for processing and generating responses.
Summary: In ChatGPT, input encoding (tokenization) and output decoding (detokenization) both happen, but the model architecture itself is decoder-only—there is no separate encoder block as in some other transformer models.
Q: How does BERT work, and what issues did it address that led to the development of transformers?
- How BERT Works:
- BERT (Bidirectional Encoder Representations from Transformers) is a transformer-based model that uses only the encoder part of the transformer architecture.
- It processes input text in both directions (left-to-right and right-to-left) simultaneously, allowing it to capture context from both sides of a word.
- The input text is tokenized and converted into embeddings, which are then passed through multiple encoder layers.
- BERT is pre-trained using two main objectives:
- Masked Language Modeling (MLM): Randomly masks some tokens in the input and trains the model to predict them.
- Next Sentence Prediction (NSP): Trains the model to understand the relationship between pairs of sentences.
-
After pre-training, BERT can be fine-tuned for various NLP tasks like classification, question answering, and named entity recognition.
-
Issues Addressed by Transformers (and BERT):
- Before transformers, models like RNNs and LSTMs were used for NLP tasks, but they had limitations:
- Difficulty capturing long-range dependencies due to sequential processing.
- Slow training and inference because of their step-by-step nature.
- Limited ability to parallelize computations.
- Transformers introduced self-attention mechanisms, allowing models to:
- Capture relationships between all words in a sequence, regardless of distance.
- Process sequences in parallel, greatly improving efficiency and scalability.
- BERT leveraged these advantages by using a deep, bidirectional encoder stack, enabling richer contextual understanding and better performance on a wide range of NLP tasks.
Summary: BERT uses a bidirectional transformer encoder to deeply understand context in text, overcoming the limitations of earlier sequential models like RNNs/LSTMs by enabling parallel processing and capturing long-range dependencies through self-attention.
Q: What is your end-to-end approach and which AWS services would you use to deploy a Docker/Kubernetes-based AI agent on AWS?
-
Overview: To deploy a containerized AI agent (using Docker and Kubernetes) on AWS, I would follow a structured, production-grade approach focusing on scalability, security, automation, and observability. My experience with enterprise AI deployments (e.g., KGPT, MCP, UIDS) has involved similar architectures.
-
Step-by-Step Approach:
- 1. Containerization:
- Package the AI agent and its dependencies into a Docker image.
- Store the image in a container registry (Amazon ECR).
- 2. Infrastructure Provisioning:
- Use Infrastructure-as-Code (Terraform or AWS CloudFormation) to provision resources.
- Set up a secure VPC, subnets (across multiple AZs), security groups, and IAM roles.
- 3. Kubernetes Cluster Setup:
- Deploy an Amazon EKS (Elastic Kubernetes Service) cluster for managed Kubernetes.
- Configure node groups (e.g., m6a.4xlarge instances for compute-intensive workloads).
- Enable auto-scaling for high availability and cost optimization.
- 4. Secrets & Configuration Management:
- Store sensitive data (API keys, DB passwords) in AWS Secrets Manager.
- Use ConfigMaps and Kubernetes Secrets for runtime configuration.
- 5. CI/CD Pipeline:
- Implement CI/CD using Azure DevOps or AWS CodePipeline.
- Automate Docker image builds, tests, and deployments to ECR and EKS.
- Use Git as the source of truth for code and IaC templates.
- 6. Deployment & Orchestration:
- Deploy the AI agent as Kubernetes Deployments/Services.
- Use ALB (Application Load Balancer) for ingress and traffic management.
- Set up DNS routing with Route 53 for endpoint exposure and failover.
- 7. Storage & Data Management:
- Use EBS for persistent storage, S3 for archival, and RDS/Aurora for structured data.
- Ensure encryption at rest (KMS) and in transit.
- 8. Observability & Monitoring:
- Integrate CloudWatch Logs, Metrics, and X-Ray for monitoring and tracing.
- Set up alerts for health checks, scaling events, and failures.
- 9. Security & Compliance:
- Enforce IAM roles/policies, IRSA for pod-to-AWS authentication.
- Enable network policies and security groups for traffic control.
- Implement backup strategies using AWS Backup.
- 10. Cost Optimization & Governance:
- Monitor resource usage and costs with AWS Cost Explorer and CloudWatch.
-
Use auto-scaling and spot instances where appropriate.
-
Key AWS Services Used:
- Amazon ECR (Elastic Container Registry)
- Amazon EKS (Elastic Kubernetes Service)
- AWS IAM (Identity and Access Management)
- AWS VPC, Subnets, Security Groups
- AWS Secrets Manager, ConfigMap, Kubernetes Secrets
- AWS S3, EBS, RDS/Aurora
- AWS CloudWatch, X-Ray
- AWS Backup
- AWS Route 53, ALB/NLB
- AWS KMS (Key Management Service)
-
CI/CD: Azure DevOps, AWS CodePipeline, or Jenkins
-
Resume/Project Reference:
- In my KGPT and MCP projects, I designed and deployed scalable AI solutions using EKS, ECR, Terraform, and integrated CI/CD pipelines (Azure DevOps), with robust monitoring, security, and cost controls as described above.
This approach ensures a robust, scalable, and secure deployment of AI agents on AWS, leveraging best practices from my enterprise AI deployment experience.