christova  

Tech Articles


Collated from various sources. Full copyright remains with original authors.

(https://stfalconcom.medium.com/software-design-patterns-every-dev-have-to-know-efb88accf446)

Patterns are reusable solutions to common design problems, resulting in a smoother, more efficient development process. They serve as blueprints for building better software structures. These are some of the most popular patterns:

  • Abstract Factory: Family Creator – Makes groups of related items.
  • Builder: Lego Master – Builds objects step by step, keeping creation and appearance separate.
  • Prototype: Clone Maker – Creates copies of fully prepared examples.
  • Singleton: One and Only – A special class with just one instance.
  • Adapter: Universal Plug – Connects things with different interfaces.
  • Bridge: Function Connector – Links how an object works to what it does.
  • Composite: Tree Builder – Forms tree-like structures of simple and complex parts.
  • Decorator: Customizer – Adds features to objects without changing their core.
  • Facade: One-Stop-Shop – Represents a whole system with a single, simplified interface.
  • Flyweight: Space Saver – Shares small, reusable items efficiently.
  • Proxy: Stand-In Actor – Represents another object, controlling access or actions.
  • Chain of Responsibility: Request Relay – Passes a request through a chain of objects until handled.
  • Command: Task Wrapper – Turns a request into an object, ready for action.
  • Iterator: Collection Explorer – Accesses elements in a collection one by one.
  • Mediator: Communication Hub – Simplifies interactions between different classes.
  • Memento: Time Capsule – Captures and restores an object’s state.
  • Observer: News Broadcaster – Notifies classes about changes in other objects.
  • Visitor: Skillful Guest – Adds new operations to a class without altering it

🧠 Summary of Debugging Process

1. Set breakpoints : Observe where error occurs

2. Start debugger : Launch program under observation

3. Step through code (F7, F8) : Watch variables change in real time

4. Inspect variables in context : Confirm null values before crash

5. Use stack trace + call stack view : Trace back to root cause

ChatGPT API Call:

I would like a real Java (NullpointerException) debugging walkthrough with stack traces and step-by-step breakpoints

  • Skiplist: a common in-memory index type. Used in Redis
  • Hash index: a very common implementation of the “Map” data structure (or “Collection”)
  • SSTable: immutable on-disk “Map” implementation
  • LSM tree: Skiplist + SSTable. High write throughput
  • B-tree: disk-based solution. Consistent read/write performance
  • Inverted index: used for document indexing. Used in Lucene
  • Suffix tree: for string pattern search
  • R-tree: multi-dimension search, such as finding the nearest neighbour

#databases #DataStructures

1. Training. To train a ChatGPT model, there are two stages:

- Pre-training: In this stage, we train a GPT model (decoder-only transformer) on a large chunk of internet data. The objective is to train a model that can predict future words given a sentence in a way that is grammatically correct and semantically meaningful similar to the internet data. After the pre-training stage, the model can complete given sentences, but it is not capable of responding to questions.

- Fine-tuning: This stage is a 3-step process that turns the pre-trained model into a question-answering ChatGPT model:

1). Collect training data (questions and answers), and fine-tune the pre-trained model on this data. The model takes a question as input and learns to generate an answer similar to the training data.

2). Collect more data (question, several answers) and train a reward model to rank these answers from most relevant to least relevant.

3). Use reinforcement learning (PPO optimization) to fine-tune the model so the model's answers are more accurate

2. Answer a prompt

Step 1: The user enters the full question, “Explain how a classification algorithm works”.

Step 2: The question is sent to a content moderation component. This component ensures that the question does not violate safety guidelines and filters inappropriate questions.

Steps 3-4: If the input passes content moderation, it is sent to the chatGPT model. If the input doesn’t pass content moderation, it goes straight to template response generation.

Step 5-6: Once the model generates the response, it is sent to a content moderation component again. This ensures the generated response is safe, harmless, unbiased, etc.

Step 7: If the input passes content moderation, it is shown to the user. If the input doesn’t pass content moderation, it goes to template response generation and shows a template answer to the user.

Enter your email to subscribe to updates.