· 약 1분
Location-Aware Deep Neural Network Review
· 약 3분
Architecture
Wall Detection

- Pre-process floor images to gray scale.
- Apply Otsu's threshold and thinned method.
- Enhance the contrast of wall lines using Canny edge detection.
- Employ Hough Transform to detect and map wall lines.
3D Visualization
Limitations
- Building structural details are unavailable or drone operations are restricted.
- Highly irregular floor plans or buildings constructed with unique materials not extensively represented in the training data.
- Real-time data integration
- Refined deep learning architectures, and validation across varied building materials and layouts
- Enhance the framework’s scalability and practical utility.
Spider GAN
Sample
{
"nodes": [
{ "id": 0, "name": "Drone", "type": "source", "features": [1, 0, 0, 0, 0.0] },
{ "id": 1, "name": "Room1", "type": "room", "features": [0, 1, 0, 0, -70.0] },
{ "id": 2, "name": "Room2", "type": "room", "features": [0, 1, 0, 0, -75.0] },
{ "id": 3, "name": "Room3", "type": "room", "features": [0, 1, 0, 0, -80.0] },
{ "id": 4, "name": "Corridor","type": "corridor", "features": [0, 0, 1, 0, -72.0] },
{ "id": 5, "name": "Wall_R1_R2","type": "wall", "features": [0, 0, 0, 1, 0.0] },
{ "id": 6, "name": "Wall_R2_R3","type": "wall", "features": [0, 0, 0, 1, 0.0] }
],
"edges": [
{ "source": 0, "target": 1, "attenuation_db": 5.0 },
{ "source": 1, "target": 5, "attenuation_db": 8.0 },
{ "source": 5, "target": 2, "attenuation_db": 8.0 },
{ "source": 2, "target": 6, "attenuation_db": 10.0 },
{ "source": 6, "target": 3, "attenuation_db": 10.0 },
{ "source": 2, "target": 4, "attenuation_db": 3.0 }
]
}
Ref
- Hason Rudd, D., Sanin, C., En, K. M., Gao, X., Islam, M. R., Hasan, M., Wang, X., Huo, A., & Xu, G. (2025). Location-Aware Deep Neural Network for Predicting Indoor 5G RSSI and CQI Using Drone-Based External RF Sensing. Procedia Computer Science, 270, 4765–4775.
https://doi.org/10.1016/j.procs.2025.09.602
Vocabulary for AI 012
· 약 3분
Vocabulary & Expressions
| Term/Expression | Definition | Simpler Paraphrase | Meaning |
|---|---|---|---|
| plurality | the state of being plural or multiple | multiplicity | 복수성, 다수 |
| premise | a statement or proposition from which another is inferred or follows as a conclusion | assumption | 전제 |
| taxonomy | the classification of something, especially organisms | classification | 분류 |
| PII scrubbed | the process of removing personally identifiable information from data sets | data anonymization | 개인 식별 정보 제거 |
| Air-gapped Environment | a secure computer network that is physically isolated from unsecured networks | isolated network | 격리된 네트워크 |
| attenuation | the reduction of the force, effect, or value of something | reduction | 감쇠 |
| CQI | Channel Quality Indicator; a measure of the quality of a communication channel | channel quality measure | 채널 품질 지표 |
| IBC | In-Building Coverage; the ability of a wireless communication system to provide coverage within buildings | indoor coverage | 실내 커버리지 |
| RSRP | Reference Signal Received Power; a measure of the power level of a reference signal in a wireless communication system | reference signal power measure | 기준 신호 수신 전력 |
| RSRQ | Reference Signal Received Quality; a measure of the quality of a reference signal in a wireless communication system | reference signal quality measure | 기준 신호 수신 품질 |
| RSSI | Received Signal Strength Indicator; a measure of the power present in a received radio signal | signal strength measure | 수신 신호 세기 지표 |
| encompass | to surround or include comprehensively | to include | 포함하다, 둘러싸다 |
| accommodate | to provide space or make adjustments for something | to make room for | 수용하다, 적응하다 |
| acquisition | the process of getting something | obtaining | 획득, 습득 |
| comprise | to consist of or be made up of | to include | 포함하다, 구성하다 |
| attenuation coefficient | a measure of how much a material reduces the intensity of a signal passing through it | signal reduction measure | 감쇠 계수 |
| calibration | the process of adjusting and standardizing the accuracy of a measuring instrument or system | adjustment for accuracy | 보정, 교정 |
| obstruction | something that blocks or hinders progress or movement | blockage | 장애물 |
| annotate | to add notes or comments to a text or diagram | to comment on | 주석을 달다 |
| equidistantly | at equal distances | uniformly spaced | 등거리로 |
| intricate | very complicated or detailed | complex | 복잡한, 정교한 |
| induce | to cause something to happen or exist | to bring about | 유도하다, 초래하다 |
| delineate | to describe or mark the edge of something | to outline | 윤곽을 그리다, 묘사하다 |
| account for sth | to explain or justify something | to explain | ~을 설명하다 |
| calibrate | to adjust or standardize a measuring instrument or system | to adjust for accuracy | 보정하다, 교정하다 |
| extrude | to force or push something out | to expel | 밀어내다, 추출하다 |
| affirm | to state or assert positively | to confirm | 확언하다, 단언하다 |
| substantially | to a great extent or degree | significantly | 상당히, 크게 |
| applicability | the quality of being relevant or suitable | relevance | 적용 가능성 |
| adaptability | the ability to adjust to new conditions | flexibility | 적응성 |
| interfere | to obstruct or disrupt | to hinder | 방해하다 |
| degradation | the process of declining in quality or condition | deterioration | 저하, 악화 |
| counterargument | an argument made to oppose another argument | opposing argument | 반론 |
| walk sb through sth | to slowly and carefully explain something to someone or show someone how to do something | to explain step-by-step | ~에게 ~을 차근차근 설명하다 |
| transitivity | the property of a relation where if A relates to B and B relates to C, then A relates to C | relational property | 추이성 |
| exhaustive | including all possibilities; comprehensive | complete | 철저한, 포괄적인 |
IAI +012
· 약 8분
Structural Knowledge
- Structural knowledge: the relationship between concepts and objects in the world.
- Hierarchical approach: built on classification and uses hierarchies as the structures for knowledge representation, presented in a graphical format.
- Semantic networks: nodes represent concepts, and edges represent relationships between concepts.
- Ontologies
- A formal specification of concepts, relationships, and constraints within a domain that enables machines to reason automatically.
- It defines classes (concepts), subclasses (hierarchical relations), and properties (attributes or relations) that describe how entities interact.
- Unlike simple taxonomies, ontologies also include logical axioms and constraints that specify allowable relationships and permit inference and consistency checking through automated reasoning.
- Classes: Main concepts or categories (e.g. Person, Animal).
- Subclasses: Subcategories (e.g. Dog ⊂ Animal).
- Properties: Attributes (e.g. hasPart, hasColor).
- Relations: Connection rules (e.g. MemberOf, SubsetOf).
- Constraints: Logical constraints (e.g. disjointness, transitivity) that enable inference.
Requirement of hierarchices
- Inclusiveness:
Dog ⊆ Mammal ⊆ Animal - Species/differentia:
Dog = Mammal + (barks, canine traits, etc.) - Inheritance:
Mammal: has_fur, gives_live_birth→Dog: inherits all Mammal properties - Transitivity: If
Dog ⊆ MammalandMammal ⊆ Animal, thenDog ⊆ Animal - Systematic and predictable rules for association and distinction
- Mutual exclusivity:
Reptile ∩ Mammal = ∅ - Necessary and sfficient criteria:
- Necessary:
- Sufficient:
Advantage of hierarchical approach
- Inferring from incomplete evidence (if the shared criteria are not obvious or easily observable).
Animal → Mammal → Dog: If an entity is classified as a Mammal, we can infer properties such as having fur and giving live birth, even if the entity is not explicitly identified as a Dog.
- Excellent representations in mature domains
- Domains where entities and relationships are well understood and stable
- e.g. medical diagnosis, biological taxonomy, type systems in programming languages.
- Useful for entities that are well defined and have clear class boudnaries.
- Good fit: HTTP status codes, chemical elements, and biological species
- Poor fit: emotions, social roles, and cultural practices
- Some theory or model is necessary to guide the identification
- Provides criteria for defining entities and relationships
- e.g. Evolutionary theory in biological taxonomy, Type theory in programming languages
Partition
A partition of a category is a set of subcategories that form a disjoint, exhaustive composition of that category.
- Disjoint: Two or more categories are disjoint if they don't share common members.
- Exhaustive composition: The subcategories together cover all members of the parent category, leaving no member unclassified.
- Examples:
- ❌ Category: Animal (Not a partition)
- Mammal, Bird (Reptiles, fish, insects are missing, not exhaustive)
- ✅ Category: Integer (Partition)
- Even, Odd (Disjoint and exhaustive)
- ❌ Category: Animal (Not a partition)
Physical composition
- PartOf Relation:
Partof(a, b)is a relation representing that one thing, 'a', is a part of another thing, 'b'. - BunchOf Relation:
BunchOf(a)is a relation, taking a set of objects 'a', to represent a composite object made up of those parts. - Examples:
Partof(Wheel, Car): A wheel is part of a car (one-to-one relation).BunchOf({Wheel1, Wheel2, Wheel3, Wheel4}): A car is a bunch of four wheels (many-to-one relation).
- Link between
PartOfandBunchOf: - Why useful?
- Reasoning from individual
parts -> group -> larger object. - Avoiding ambiguity between: "this thing is part of", "these things together form"
- Without
BunchOf, ontologies cannot represent: piles, colleciton, aggregates, composite physical structures.
- Reasoning from individual
Measurements
- Quantitive measures (Ratio, Interval)
- Represented as numbers with units
- Support arithmetic and unit conversion
- Enable numeric reasoing (e.g. 2.54cm = 1 inch)
- Non-quantitative measures (Ordinal)
- Cannot be meaningufully represented as numbers
- Can still be compared using ordering relactions (
<,>,=) - Suppor qualitative reasoning (e.g. one task is more difficult than another)
Objects
- Stuff
- Represents substances
- Uncountable masses
- Definitions include only intrinsic properties (e.g. Butter, Unsalted Butter)
- Things
- Represents discrete objects
- Countable entities
- Definitions include extrinsic properties (e.g. PoundOfButter, StickOfButter)
- It depends on measurement
- It depends on contextual constraints
Time
- Fluent: a condition whose truth value can change over time.
- e.g. "The box is on the table", ,
- a time-dependent proposition.
- Time scale and absolute time
- Ontology represents time along a single continuous timeline with a fixed reference point.
- It allows arithmetic operations on time and comparisons between time points.
- Time intertvals
- Time can be represented as moments (instants) or intervals (durations).
- Partition of time
- All time intervals can be partitioned into moments and extended (non-zero-length) intervals.
- It provides a complete and precise ontology of time.
Event calculus
- : Fluent is true for all time between time and .
- : Event start at time and ends at time .
- : Event causes fluent to become true at time .
- : Event causes fluent to cease to be true at time .
- : Fluent becomes true at some point between and .
- : Fluent ceases to be true at some point between and .
- : Time point occurs before time point .
- Happens(PutBoxOnTable, 10, 12)
- Initiate(PutBoxOnTable, On(Box, Table), 12)
- Initiated(On(box, table), 10, 12)
- T(On(Box, Table), 12, 20)
- Terminates(RemoveBoxFromTable, On(Box, Table), 20)
- Terminated(On(box, table), 18, 22)
Successor-state axiom
후속상태공리
- Define how the world changes after an action occurs.
- what changes when an action happens
- what stays the same.
- Without successor-state axioms, we face the frame problem:
- after every action, we would need to explicitly list all facts that did not change.
- : moving block A from the top of block B to position X.
- Preconditions:
- : A is on top of B
- : nothing is on top of A
- : nothing is on position X
- Effects:
- : A is now on position X
- : B is now clear
- : X is no longer clear (X is now occupied by A)
- Preconditions:
Semantic networks
- Visually represent a knowledge base.
- Support efficient inference.
- Allow properties of an object ot be inferred from its category membership.
- Representing individual objects, categories of objects, and relations among objects.
- Categories are the primary buildling blokcs of large-scale knowledge representation schemes.
Taxonomy hierarchy
- A hierarchical structure of categories
- Each lower category is a more specific kind of its parent
- Organized from general → specific
University Ontology
| Entity | Class | Example Statemnets |
|---|---|---|
| Alice | Student | , |
| Prof.Smith | Lecturer | , |
| CS101 | Course |
Knowledge graph
- represents information and its relationships using a graph structure.
- Nodes: entities or concepts (e.g. people, places, things).
- Edges: relationships between nodes (e.g. "is a", "part of", "located in").
Types of Knowledge Graphs
- General Knowledge Graphs
- Domain-Specific Knowledge Graphs
- Semantic Knowledge Graphs
- Social Knowledge Graphs
- Temporal Knowledge Graphs
- Special Knowledge Graphs
- Statistical Knowledge Graphs
- Probabilistic Knowledge Graphs
- Textual Knowledge Graphs
- Multi-modal Knowledge Graphs
General Knowledge Graphs
- Comprehensive information representation
- Entity-Relationship Structure
- Linked Data
- Semantic Enrichment
- Capabilities & Use Cases
- Querying and Analysis
- Data Integration
- ML and AI applications
Examples
- DBPedia: RDF, resource descritions framework
- Wikidata
- YAGO
- Google Knowledge Graph
- Microsoft Academic Graph
- IBM Watson Knowledge Studio
Reasoning for categories
- Infer the presence of certain objects from perceptual input
- Infer category membership from perceived properties
- Use category information to make predictions
- It enables an agent to identify objects from observed properties and to predict further characteristics using category knowledge.
Reasoning using Semantic networks
- Semantic networks are:
- systems designed specifically for organizing categories reasoning with categories.
- Provide graphical representations of a knowledge base
- Using a semanctic network, reasoning can be performed based on:
- relationships between objects
- category membership
- inheritance between categories
- properties associated with categories
- Allows an object to inherit general knowledge from its category.
- The inheritance algorithm:
- Starts from the object itself
- Follows links upwards through the category hierarchy
- Stops as soon as it finds a value for the property
- This suppors efficient reasoning, default values, and exception handling.
RDF
Resource Description Framework (RDF)
- Triple Structure:
subject -> predicate -> object - Subject: represents the resource being described or identified by a URI.
- Predicate (or Property): desribes the relationship between the subject and the object. also represented by a URI.
- Object: represents the value or target of the relationship. It can be a URI or a literal (a string, number, or date).
IAI +011
· 약 10분
Uncertain Domain
- Agent may need to handle uncertainty
- Environment is partially observable
- Fully observable: An agent knows where it is.
- The drone never knows its exact position, only an estimated one.
- The true user intent is not directly observable, only noisy speech data.
- It cannot see the whole environment or detect humans perfectly.
- The true health state (disease present or not) is hidden.
- Environment is non-deterministic
- AI Trading Agent
- even if the agent takes the same action, the outcome can vary dramatically.
- from market prices changes unpredictably due to external events (news, other traders, economic data).
- network latency, competing traders' behavior are stochasic and independent, random fluctuations can affect the outcome.
- buy action could lead to profit, loss, or no change depending on uncontrollable external factors.
- AI Helpdesk Chatbot
- even when the chatbot executes the same action, it sends queries to multiple backend systems, the result may differ each time.
- network latency or failures, backend load, concurrent requests, and external dependencies can lead to different response times or outcomes.
- same command doesn't guarantee the same outcome.
- AI Trading Agent
- Autonomous Driving
- Partial Observability
- Sensors cannot detect everything, blind spots, weather effects, occluded vehicles.
- Non-Determinism
- Even if the car signals a turn and starts moving, other drivers might brake suddenly, pedestrians might cross unexpectedly, or traffic lights might malfunction.
- depending on random external events.
- Partial Observability
- Medical Diagnosis & Treatment Assistant
- Partial Observability
- The patient's internal health state is not directly visible.
- tests can be inaccurate or incomplete: false positives/negatives, missing data
- Non-Determinism
- The same treatment can have different effects on different patients due to genetics, lifestyle, or random biological responses.
- A drug may succeed, fail, or cause side effects.
- Partial Observability
Bayes' Theorem
- : Posterior probability, the probability of event A given taht B has occurred.
- : Likelihood, the probability of event B occurring given that A is true.
- : Prior probability, the initial probability of A being true before considering B.
- : Evidence, the total probability of B occurring.
- examples
- 1% of people have a certain disease (prior probability).
- the test for the disease is 99% accurate (likelihood).
- so
-
-
- the conditional probability quantifies the relationship in the causal direction from cause to effect.
- but is often what we really want to know, describing the relationship in the diagnostic direction from effect to cause.
- In medical dignosis, the doctor knows from medical studies, and want to derive a for a particular patient.
General Form of Bayes' Rule
- is the normalization constant needed to make the entries in sum to 1 for each value of X.
- conditional independency
- two variables X and Y are conditionally independent given a third variable Z if the value of X provides no information about Y once Z is known.
Constructing Bayesian Network
- constructing a Bayesian network in which resulting joint probability distributions are a good representation of the agent's knowledge.
-
-
- rewrite the entries in the joint probability distribution in terms of conditional probabilities using the product rule.
-
- repeat step 2 until all variables are included.
Knowledge Representation
- The agent's knowledge can at best provide only a degree of belief in the relevant logical sentences.
- A probabilistic agent may have a numerical degree of belief between 0 and 1.
Bayesian Network
- a directed graph
- each node repressents a random variable and edge with an arrow from X to Y represents that X is a parent of Y.
- each node is associated with a probability distribution
- if a node Y has parents X, the Y node has a conditional probability distribution with respect to its parents X, i.e.
- if a node has no any parents, it has an unconditional probability distribution.
Burglary Example
- a new burglar alarm installed at home.
- it is reliable at detecting a burglary, but also responds on occasion to minor earthquakes
- you have two neighbors, John and Mary who promised to call you at work when they hear the alarm.
- given the evidence of who has or has not called, estimate the probability of a burglary.
- Knowledge representation as the probability of each event that can occur in this case.
- calulate the full joint probability distribution for all relevant variables.
- specifying probabilities for all possible events one by one is unnatural and tedious.
Probabilistic reasnoing
- to explain how to use network models to reason under uncertainty.
- Exact inference: calculate the exact posterior probabilities.
- Approximate inference: Stochastic approximation techniques such as likelihood weighting and Markov Chain Monte Carlo
- can give reasonable estimates of the true posterior probabilities in a network
- can cope with much larger networks than exact inference algorithms.
- Static worlds: Each random variable has a single fixed value.
- Dynamic worlds: view the world as a series of snapshots, or time slices.
- Each of snapshots contains a set of random variables, some observed and some hidden.
- The values of these variables can change over time.
- With the assumption of state sequences are Markov, the future is independent of the past given the present.
Inference in Bayesian Networks
- Computing the posterior probability distribution of a set of query variables, given some observed events, called some assignment of values to a set of evidence variables.
- : query variable(s)
- is it raining?
- : the set of evidence variables with observed values
- weather report says it is cloudy.
- weather report says there is high humidity.
- : a particular observed event.
- : the non-evidence, non-query variables.
- the other variables in the network.
-
- the complete set of variables in the network.
- : the posterior probability distribution of the query variable(s) given the evidence.
Exact inference in Bayesian Networks
- One exact inference method is called by inference by enumeration.
- Observed some event and , want to compute the posterior probability distribution .
- Use the full conditional probability table
- Use the Bayesian Network
- It calculates all the required probability components in each branch in the evaluation tree, and this results in repetitive calculations.
- To avoid this, we can use variable elimination algorithm and clustering algorithms.
- Calculation of probability distribution for a query variable is complexity exponential.
- Enumeration method can become intractable in large, multiple connected networks.
->use approximate inference methods.
For any Bayesian network with given nodes, , the joint probability distribution is given by:
Using the Bayesian network, we can compute the conditional probability.
Berglary example calculation:
FDA +011
· 약 4분
Bias
- Bias quantifies how much on average the predicted values differ from the actual values.
- High bias implies the model is under-performing.
Variance
- Variance quantifies how sensitive the model is to small changes in the training samples.
Ensemble Methods
- The intuition behind ensemble methods is to decrease bias and variance by using multiple machine learning algorithms.
- Any machine learning algorithm can be used in ensemble methods.
- decision trees, neural networks, logistic regressions, etc.
- Base models are as diverse as possible.
- Train each base model to predict as accurately as possible.
Sequential ensemble methods
- Arrange weak learners in a sequence, such that weak learners learn from next learner in the sequence to create better predictive models.
- Each model fits the residual of its predecessor.
Parallel ensemble methods
- to use different variations of the same dataset, of the smae classifier, and aggregate the results.
Bootstraping
- Sampling technique that creates multiple subsets of datasets from the original dataset.
- when inferring results for a population from results found on a collection of smaller random samples of that population.
Bagging
Bootstrap aggregating
- Generates subsets (bags) of traning data by sampling from the original training dataset with replacement.
- To overcome the complexity of models that overfit the training data.
Boosting
- fits multiple models sequentially
- each model in the sequence is fitted giving more weight to the data points that were poorly handled by the previous models in the sequence.
- This process is iterated until the error function does not change, or the maximum limit of the number of estimators is reached.
Random Forest
- Shallow trees have lower variance and higher bias, whereas deep trees have low bias but high variance.
- Shallow trees are chosen for sequential ensemble methods
- Deep trees are chosen for bagging methods (or parallel ensemble methods).
- a bagging method where deep trees are used and fitted on bootstrap samples, and then combined to produce an output with lower variance.
- selects randomly a set of features which are then used to decide the best split at each node of the tree.
- can be applied to both regression and classification tasks.
- can learn binary features, categorical features and numerical features.
- create from the original dataset multiple bootstrap samples.
- at each node in the decision tree, a random set of features is considered to decide the most beneficial split.
- train a decision tree on each bootstrap sample.
- final prediction is computed by averaging the prediction from all decision trees combined.
Advantages of Random Forest
- generally accurate, quick to train
- can handle very large datasets
- can estimate importance of features
- generates an internal unbiased estimate of accuracy, which can use to know when to stop buildling
- can handle missing data
- can handle datasets with imbalanced classes
- can compute proximity between data points
- unsupervised for clustering and outlier detection
but don't handle large numbers of irrelevant attributes as well as some other methods.
Applications of Random Forest
| Industry | Applications | Purpose / Advantages |
|---|---|---|
| Finance | Assessing high credit-risk customers, detecting fraud, and addressing option pricing problems | Preferred over other algorithms due to its ability to minimize time spent on data management and pre-processing tasks |
| Healthcare | Gene expression classification, biomarker discovery, and sequence annotation | Helps doctors estimate drug responses to specific medications |
| E-commerce | Recommendation engines | Used to achieve cross-selling objectives |
AdaBoost
Adaptive Boosting
- simplest boosting algorithm, usaully uses decision trees for modelling
- multiple sequential models are created, each correcting the errors from the previous model.
GBM
Gradient Boosting Machine
- works on both regression and classification problems.
- usually, regression trees are used as base models.
XGBoost
eXtreme Gradient Boosting
- another implementation of gradient boosting algorithm.
- has proven to be a highly effective machine learning algorithm.
- extensively used in machine learning competitions due to its speed and performance.
Combining predictions
Voting
- Hard voting selection process uses predicted class labels for majority rule voting.
- Soft voting uses the predicted probabilities given by each base model, and the class label with the maximum sum of its probabilities is selected.
- where is the number of base models, and is the probability predicted by model for class given input .
FSD +009
· 약 5분
Exception
- Exeptions are throwable objects.
- Checked Exceptions are checked by the compiler and should be handled (thrown or caught).
- Unchecked or runtime Exceptions are not flagged by the compiler. Their occurrence during execution interrupts the program.
- Exceptions can be thrown by developers. Throwing an exception delegates handling the exception to a different class or different level of the program.
- Thrown exception is left not handled, it will cause runtime error.
Error
- Java Errors usually indicate problems with the JVM or system resources.
- it is not meant to be caught or handled by applications.
- the base class is Error.
- Python is no separate Error class hierarchy. Errors are represented as exceptions.
- ValueError, TypeError, MemoryError, SystemError, etc. are subclasses of Exception.
Java vs Pythone Exceiptions
| Feature | Java | Python |
|---|---|---|
| Syntax | try-catch-finally | try-except-else-finally |
| try | attempts to execute a block of code | attempts to execute a block of code |
| catch/except | execute alternative code if exception arises | execute alternative code if exception arises |
| finally (optional) | executes code regardless of try/catch outcome | executes code regardless of try/except outcome |
| else (optional) | X | executes code if no exception arises |
public class ExceptionExample {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
try {
System.out.print("Enter first number: ");
int a = scanner.nextInt();
System.out.print("Enter second number: ");
int b = scanner.nextInt();
int result = a / b; // This will raise ArithmeticException
System.out.println("Result: " + result);
} catch (ArithmeticException e) {
System.out.println("Caught an exception: " + e.getMessage());
} catch (NumberFormatException e) {
System.out.println("Caught a number format exception: " + e.getMessage());
} finally {
System.out.println("This block always executes.");
}
}
}
def div(a, b):
return a / b
a = input("Enter first number: ")
b = input("Enter second number: ")
try:
result = div(int(a), int(b)) # This will raise ZeroDivisionError
print("Result:", result)
except ZeroDivisionError as e:
print("Caught an exception:", e)
except ValueError as e:
print("Caught a value error:", e)
else:
print("No exception occurred.")
finally:
print("This block always executes.")
Throwing Exceptions
class IncorrectAgeError(Exception):
def __init__(self, age):
self.age = age
self.message = f"Age {age} is not valid. Age must be between 0 and 120."
super().__init__(self.message)
number = int(input("Enter your age: "))
try:
if number < 0 or number > 120:
raise IncorrectAgeError(number)
print(f"Your age is {number}.")
except IncorrectAgeError as e:
print(e)
File Handlers
- "r": Opens a file for reading, requires the file to exist
- "w": Opens a file for writing. If the file exists, it is truncated to zero length. If the file does not exist, a new text file is created.
- "a": Opens file for open for writing. The file is created if it does not exist.
- "+": Opens a file in updating mode (reading and writing). It can be used with reading (r+) and writing (w+) modes.
- "t": Opens a file in text mode (default mode).
- "b": Opens a file in binary mode. It can be used with reading (rb) and writing (wb) modes.
File Handler Methods
os.path.exists("file.txt") # Check if file exists
os.remove("file.txt") # Delete a file
os.remove("dir") # Delete an empty directory
os.chdir("path/dir") # Change current working directory
os.getcwd() # Get current working directory
os.mkdir("path/dir") # Create a new directory
file_handler = open("file.txt", "r") # Open a file in read mode
file_handler.read() # Read the entire file content
file_handler.readline() # Read a single line from the file
file_handler.close() # Close the file
file_handler = open("file.txt", "w") # Open a file in write mode
file_handler.write("Hello, World!") # Write to the file
file_handler.write("\n") # Write a newline character
file_handler.close() # Close the file
import csv
with open("file.txt", "r") as file_handler: # Using 'with' to handle file
csv_object = csv.reader(file_handler)
for row in csv_object:
print(row)
file_handler.close()
with open("file.txt", "a") as file_handler: # Append mode
csv_writer = csv.writer(file_handler)
row = ["1", "gracefullight", "100"]
csv_writer.writerow(row)
file_handler.close()
import json
with open("data.json", "r") as file_handler:
data = json.load(file_handler) # Load JSON data from file
print(data)
file_handler.close()
with open("data.json", "w") as file_handler:
json.dump(data, file_handler) # Write JSON data to file
file_handler.close()
- InputStream: reads byte-based input from various sources like files, memory, or network connections.
- OutputStream: writes byte-based output to various network connections.
Unit Testing
- tests and verifies the smallest unis of an application such as functions, procedures, modules, or objects.
- the conducted during the development phase of the SDLC.
- Developers aim to identify defects and code bugs, which can save time and reduce costs in later testing stages.
- software testing encompasses the fourmain testing phases, and unit testing is at the foundational level of the process.
- Unit Testing
- Integration Testing
- System Testing
- Acceptance Testing
Python unit testing
- test cases are defined using classes that inherit from
unittest.TestCase - assertions are used to validate results
self.assertEquals() - the
unittest.TextTestRunnerclass can be used to run tests
import unittest
class TestMathOperations(unittest.TestCase):
def test_addition(self):
self.assertEqual(2 + 3, 5)
def test_subtraction(self):
self.assertEqual(5 - 2, 3)
def test_multiplication(self):
self.assertEqual(4 * 3, 12)
def test_division(self):
self.assertEqual(10 / 2, 5)
IAI +010
· 약 11분
Knowledge representation
- Intelligent agents need knowledge about the world in order to reach good decisions.
- Declarative knowledge is represented in a form of sentences in a knowledge representation language and stored in a knowledge base.
- Knowledge base is used by an inference engine to infer a new sentence which will be used for the agent to decide what action to take next.
- Formal languages are defined by its grammar and semantic rules
- grammar: defines the syntax of legal sentences
- semantic rules: defines the meaning.
- Common knowledge representation formalisms:
- Propositional logic
- First-order logic
- Fuzzy logic
- Semantic networks
- Ontologies
Propositional logic
- a declarative language in which can handle propositions that are known true, known false, or completely (unknown true or false)
- a BNK (Backus-Naur Form) grammer of sentences in propositional logic.
- = NOT
- = AND
- = OR
- = IMPLIES
- = IF AND ONLY IF
- Negation: a sentence using is called negation
- Literal: either an atomic sentence or a negated atomic sentence
- Conjunction: two sentences connected by . Eac hof them is called conjunct
- Disjunction: two sentences connected by . Each of them is called disjunct
- Implication: two sentences connected by . . P is called premise or antecedent and Q is the conclusion or consequent.
- An implication is
if-thenstatement.
- An implication is
Truth tables
| P | Q | P | P Q | P Q | P Q | P Q |
|---|---|---|---|---|---|---|
| T | T | F | T | T | T | T |
| T | F | F | F | T | F | F |
| F | T | T | F | T | T | F |
| F | F | T | F | F | T | T |
FOL, First-order logic
- a declarative language
- Syntax of FOL builds on that of propositional logic
- terms to represent objects, universal quantifier, and existential quantifier
- a model in FOL must provide the information required to determine the truth value of every atomic sentence in the language.
- means for all x, P(x) is true
- means there exists an x such that P(x) is true
Logical equivalence
| logical equivalence | meaning |
|---|---|
| Commutativity of | |
| Commutativity of | |
| Associativity of | |
| Associativity of | |
| Double negation elimination | |
| Implication elimination | |
| Contraposition | |
| ( | Biconditional elimination |
| De Morgan's law for | |
| De Morgan's law for | |
| Distributivity of over | |
| Distributivity of over |
- For all x, not P(x) is logically equivalent to "it is not the case that there exists an x such that P(x) is true."
Reasoning
Deductive reasoning
- a process of reasoning from one or more statements (premises) to reach a logical conclusion.
- first premise, second premise, therefore conclusion.
Inductive reasoning
- the process of resoning from specific observations to borader generalizations and theories.
- also described as a method where one's experiences and observations are synthesized to cmoe up with a general truth.
- premises and then conclusion
Inference
- steps in reasoning
- moves from premises to logical consequences
- In AI Context, inference is to derive new logical sentences (as the conclusion) from existing logical sentences (as premises).
- researchers develop automated inference systems to emulate human inference.
Inference Problem
- KB, Knowledge Base, is a set of propositions that represent what is known about the world.
- , Query sentence, is the target conclusion which needs to be confirmed based on the given KB.
- where denotes the relation of logical entailment between KB and the sentence , reading as "KB entails " or "if KB is true, then must also be true".
-
- is the set of all models that satisfy .
- is the set of all models that satisfy .
- The statement means that in every model where is true, is also true. In other words, if holds, then must also hold.
- Model Checking: enumerates all possible models and checks if the entailment holds in each model.
- Knowledge base will be used to draw inferences.
- Query sentence, , is needed to be checked whether it is entailed by the KB.
- Symbols, a list of all symbols (or atomic propositions) used in the problem context.
- Models, assignments of truth and false values to those identified symbols.
- Model Checking Procedure
- Identify the propositional symbols involved in the KB sentences and query sentence
- Enumerate all possible models by assigning truth values to the identified symbols.
- Evaluate the KB sentence in each model and fined the models in which KB is true.
- Evaluate the query sentence in the models from step 3 and check if query sentence is true in these models.
- Conclude that the KB entails the query sentence if and only if the query sentence is true in all models where the KB is true.
Inference Problem Example
- Obersvation P: "It is raining"
- Query sentence Q: "The ground is wet"
- Knowledge: (If it is raining, then the ground is wet)
- Knowledge Base KB:
- Inference Problem: from KB=T, get Q=T
- Proof:
- From the 4 possible models, only Model 1 makes KB true.
- M(KB) = model 1
- Model 1 also makes Q true.
- M(Q) = model 1
- , therefore
| Model | P | Q | P Q | P (P Q) |
|---|---|---|---|---|
| 1 | T | T | T | T |
| 2 | T | F | F | F |
| 3 | F | T | T | F |
| 4 | F | F | T | F |
Inference by theorem proving
to apply rules of inference directly to the sentences in the KB to construct a proof of the desired sentence without consulting models.
- Proof: a chain of consequences that leads to the desired goal.
- KB will be used to draw inferences.
- Desired sentence is needed to be checked whether it is entailed by the KB.
- The rules of inference are the approved logical equivalences and rules.
| Aspect | Model Checking | Theorem Proving |
|---|---|---|
| 방식 | 참/거짓으로 실제 계산 | 논리 규칙을 사용해 증명 |
| 예시 | 진리표 | Modus Ponens, Resolution |
| 장점 | 단순함 | 복잡한 문장도 처리 가능 |
| 단점 | 계산 많음 | 규칙 익혀야 함 |
Modus Ponens Rule
- whenever any sentences of the form and are given, then the sentence can be inferred.
Add-Elimination Rule
- from a conjunction, one of the conjuncts can be inferred.
Terms to contradiction and resolution
CNF
┌────────────────────────────────────────────────┐
│ (P ∨ Q) ∧ (¬Q ∨ R) │
│ ┌──────────────────────┐ ┌───────────────┐ │
│ │ Clause 1 │ │ Clause 2 │ │
│ │ (P ∨ Q) │ │ (¬Q ∨ R) │ │
│ │ ┌───────┬───────┐ │ │ ┌──────┬─────┐ │
│ │ │ P │ Q │ │ │ │ ¬Q │ R │ │
│ │ └───────┴───────┘ │ │ └──────┴─────┘ │
│ └──────────────────────┘ └───────────────┘ │
└────────────────────────────────────────────────┘
- Literal: an atomic sentence or its negation
- Complementary literals: a literal and its negation are complementary literals
- Clause: an expression formed from a collection of finite literals
- In most cases, a clause is a disjunction of finite literals.
- written as the symbol .
- Conjunctive Normal Form: a sentence expressed as a conjunction of clauses.
- Satisfiability: a sentence is satisfiable if it is true in, or satisfied by, some models.
Propositional satisfiability (SAT) problem
- to determine the satisfiability of sentences in propositional logic.
- if there exists a model that satisfies a given logical sentence, then the sentence is satisfiable.
- Satisfiability can be checked by enumerating the possible models until one is found that satisfies the sentence, or by resolving complementary literals until an empty clause is derived.
- many problems in CS are really SAT problems.
Resolution rule
Unit resolution rule
- where is a literal and and are complementary literals.
- Unit resolution rule takes a clause which is a disjunction of literals, and a literal and produces a new clause as the resolvent.
Full resolution rule
- where is a literal and and are complementary literals.
- Full resolution rule takes two clauses which are disjuctions of literals and produces a new clause containing all the literals of the two original clauses except for the two complementary literals.
Inference via proof by contradiction through resolution
- to prove that , we can show that the sentence is unsatisfiable.
- by deriving an empty clause from using the resolution rule.
- In order to derive an empty clause, we use resolution which is a process to resolve complementary literals until to find an empty clause.
- R1: P (observation)
- R2: P Q (knowledge, raining implies ground is wet)
- Query sentence: Q
- Inference problem: , i.e. from , get
- Proof:
- Let valid
- Convert to CNF
- Apply implication elimination rule, one has
- Apply unit resolution rule to and , resolve and , one has
- Apply unit resolution rule to and , resolve and , one has
Inference in FOL
- convert the first-order inference to propositional inference using the ruls for quantifiers.
- universal instantiation (UI)
- existential instantiation (EI)
- do inference in propositional logic using the methods about inference in propositional logic.
- this approach to first-order logic inference via propositionalization is complete, means any entailed sentences can be proved.
- in most cases, this approach works
- in some cases, it is slow and only useful when the domain is small.
- get rid of quantifiers by instantiating them with specific constants or variables.
Universal instantiation (UI)
- to convert sentences with universal quantifiers to sentences without universal quantifiers.
- it can infer any sentence obtained by substituting a ground term for the universally quantified variable.
- denotes the result of applying the subsitution to the sentence and is a ground term or a constant symbol.
- universal instantiation can be applied many times to produce may different consequences.
-
- ...
Existential instantiation (EI)
- to convert sentences with existential quantifiers to sentences without existential quantifiers.
- the quantified variable can be replaced by a single new constant symbol.
- for any sentence , variable , and constant symbol not appear elsewhere in the knowldge base, the following rule is sound:
- denotes the result of applying the subsitiution in the sentence and is ground term or a new constant symbol.
- Existential instantiation can be applied only once, and then the existentially quantified sentence can be discarded.
-
- where is a new constant symbol not appear elsewhere in the knowledge base
CNF, Conjunctive Normal Form
| Step | Rule Name | Description | Example |
|---|---|---|---|
| 1 | 제거 | , 없애기 | → |
| 2 | De Morgan's | 분배 | |
| 3 | Double negation | 이중부정 제거 | |
| 4 | Distribution | over 분배 | → |
| 5 | And-Elimination | 분리 | 따로 |
Vocabulary for AI 011
· 약 5분
Vocabulary & Expressions
| Term/Expression | Definition | Simpler Paraphrase | Meaning |
|---|---|---|---|
| formalism | a system of rules and symbols used to represent concepts in a precise and unambiguous way | structured system | 형식주의, 형식 체계 |
| disjoint | not connected or related | separate | 분리된, 연결되지 않은 |
| caveat | a warning or cautionary detail to consider | warning | 경고, 주의 사항 |
| instantaneous | happening immediately | immediate | 즉각적인, 순간적인 |
| dweller | a person or animal that lives in a specific place | inhabitant | 거주자, 주민 |
| scanty | insufficient in quantity or quality | meager | 부족한, 빈약한 |
| synthesize | to combine different elements to form a coherent whole | combine | 합성하다, 종합하다 |
| angstrom | a unit of length equal to one ten-billionth of a meter, used to measure very small distances | unit of length | 옹스트롬 (10억분의 1미터) |
| treaty | a formal agreement between two or more countries | agreement | 조약, 협정 |
| entice | to attract or tempt by offering something desirable | attract | 유혹하다, 꾀다 |
| simplistic | treating complex issues in an overly simple way | oversimplified | 지나치게 단순화된 |
| Event Calculus | a formalism for representing and reasoning about events and their effects over time | temporal reasoning system | 이벤트 연산 |
| reify | to make something abstract more concrete or real | concretize | 구체화하다, 실체화하다 |
| reification | the process of making an abstract concept more concrete or real | concretization | 구체화, 실체화 |
| cease | to stop or bring to an end | stop | 중단하다, 멈추다 |
| exogenous | originating from outside a system | external | 외부의, 외생적인 |
| reign | to hold royal office; to rule as a monarch | rule | 통치하다, 군림하다 |
| obscured | hidden or made less visible | hidden | 가려진, 숨겨진 |
| by virtue of | because of; as a result of | because of | ~덕분에, ~때문에 |
| semidecidable | a property of a problem where a solution can be verified if given, but not necessarily found | partially decidable | 반결정 문제 |
| singly | one at a time; individually | one at a time | 하나씩, 개별적으로 |
| negate | to nullify or make ineffective | nullify | 부정하다, 무효화하다 |
| subsumption | the process of including one concept within another, more general concept | inclusion | 포섭, 포함 |
| thrust | the main idea, subject, or opinion that is discussed or written about | main idea | 요지, 핵심 |
| tractability | the quality of being easy to manage or deal with | manageability | 계산 가능성 |
| resolvent | a clause derived from two clauses containing complementary literals, used in resolution-based theorem proving | derived clause | 해석자, 해결책 |
| propositionalzation | the process of converting first-order logic statements into propositional logic statements | conversion to propositional logic | 명제화 |
| transduction | the process of converting one form of data into another | data conversion | 변환, 전환 |
| transductive learning | a type of machine learning where the model makes predictions on specific test cases based on the training data, rather than generalizing to unseen data | case-based learning | 전이 학습 |
| representation | the way in which information or knowledge is structured and organized | depiction | 표현, 나타냄 |
| dispense | the act of distributing or providing something | distribution | 분배, 제공 |
| factor | to break down a problem into smaller, more manageable parts | breakdown | 분해하다 |
| inherently | in a way that is a permanent, essential, or characteristic attribute | intrinsically | 본질적으로, 내재적으로 |
| preclude | to prevent something from happening or to make it impossible | prevent | 배제하다, 막다 |
| integral | necessary to make a whole complete; essential | essential | 필수적인, 완전한 |
| eschew | to deliberately avoid or abstain from something | avoid | 피하다, 삼가다 |
| logarithmically | in a way that relates to logarithms or logarithmic functions | in terms of logarithms | 로그적으로 |
| counteract | to act in opposition to something to reduce its effect | oppose | 대응하다, 반작용하다 |
| point-wise | applying a function or operation to each individual element separately | individually | 점별로, 개별적으로 |
| tedious | too long, slow, or dull; tiresome or monotonous | boring | 지루한, 따분한 |
| multiplicative | relating to multiplication or the process of multiplying | relating to multiplication | 곱셈의, 증가하는 |
| leftward | moving or directed to the left | to the left | 왼쪽으로 |
| recurrence | the act of returning or happening again | return | 재발, 반복 |
| sinusoid | a mathematical curve that describes a smooth, periodic oscillation | wave-like curve | 사인 곡선 |
| desideratum | something that is desired or wanted | desired thing | 바람직한 것, 필요조건 |
| contiguous | sharing a common border; touching | adjacent | 인접한, 접촉하는 |
| dilated | made larger or expanded | expanded | 확장된, 팽창된 |
| exhibit | to show or display something publicly | display | 전시하다, 나타내다 |
| regime | a system or planned way of doing things, especially one imposed from above | system | 체제, 제도 |
| perplexity | a state of confusion or uncertainty | confusion | 당혹, 혼란 |
| reliance | dependence on or trust in someone or something | dependence | 의존, 신뢰 |
Ontology
| Concept | What it is | Role / Function | Example |
|---|---|---|---|
| Ontology | The representation itself — a structured map of concepts and relations | Describes the general framework of the world | The hierarchy (Anything → PhysicalObjects → Humans, etc.) |
| Ontology System | The platform or implementation that holds and reasons about ontologies | Stores, queries, and integrates knowledge | CYC, DBpedia, Google Knowledge Graph |
| Ontological Engineering | The process of designing and maintaining ontologies | Defines general concepts and their logical structure | Defining "PhysicalObject" → later "Robot," "Television," etc. |
Semantic Network
- Semantic networks let us represent logical relationships visually, but their meaning remains purely logical — about objects, categories, and relations.
Tractability
| Aspect | Semantic Network | Description Logic | First-Order Logic |
|---|---|---|---|
| 형식성 | 낮음 (그래픽 기반) | 중간 (논리 기반) | 높음 (수학적) |
| 표현력 | 제한적 | 중간 | 매우 높음 |
| 추론 효율성 | 매우 높음 | 높음 (다항시간 목표) | 낮음 (NP-hard~undecidable) |
IAI +009
· 약 7분
Generative AI
- Gen AI refers to a category of AI models designed to generte new content, synt99hetic data that resembles a given dataset.
- Gen AI models create new content, including text, images, audio, and video.
Historcal context of Gen AI
- 1980s: The development of statistical approaches to AI emerged, focusing on probabilistic models
- 1990s: Hidden Markov Models (HMMs) became popular in speech recognition and sequence generation tasks, making a shift towards using statistical methods in generative processes.
- 1990s-2000s: The resurgence of Neural Networks, with the introduction of deep learning techniques. However, hardware and data limitations hampered progress.
- 2010s: The advent of deep learning algorithms, especially convolutional neural networks (CNNs) and recurrent neural networks (RNNs), transformed the landscape of AI.
- 2013: VAEs were introduced, providing a probabilistic approach to data generation, allowing for smooth latent space interpolation and structure.
- 2014: GANs, a novel framework where two neural networks (a generator and a discriminator) are trained simultaneously, allowing for the generation of highly realistic images and other data types.
- 2015-2020: Generative models began to find applications beyond image synthesis, including text generation, music composition, and even video generation. OpenAI's GPT-2 showcased the potential of transformer-based models for generating coherent text.
- 2020s: The introduction of larger and more capable models like OpenAI's GPT-3 and subsequent iterations revolutionized natural language processing.
- DALL-E and Stable Diffusion pushed the boundaries of image generation, allowing users to create images from textual descriptions. This sparked creative exploration and practical applications in marketing, art, and design.
- Present: The integration of multiple data modalities (text, image, audio) led to the development of models like CLIP and GPT-4, which can understand and generate content across different formats, enhancing the versatility of generative AI.
Variational Autoencoders, VAEs
- VAEs are from the probabilistic approach to build a generative AI model
- VAE learns a latent distribution instead of a fixed latent presentation, allowing for the generation of new samples.
- Latent space
- sample from a Gaussian distribution
- and are learned during training
- is a new sample from the latent space
- is the encoder that maps input data to a distribution over the latent space
- is the decoder that maps a latent variable back to the data space
- During training, the model optimizes the reconstruction loss and a regularization term (KL divergence) to ensure the learned latent distribution is close to a prior distribution (usually a standard normal distribution).
- Latent Representation
- Dimensionality Reduction: latent space is typically lower-dimensional than the input space
- Smoothness: In a well-structured latent space, similar inputs will be represented by nearby points.
- Generative Capabilities: Once trained, can sample from the latent space to generate new data that resembles the training set.
- Regularization: The VAE incorporates a regularization term in its loss function (KL divergence), which encourages the lerned latent distribution to be close to a standard normal distribution.
- Decoder
- The decoder takes the sampled latent representation and reconstructs the original input data.
- The goal is to make the reconstructed data as close as possible to the original input.
VAE Examples
Face Generation Example
- Trains a VAE on face photos.
- Latent space learns meaningful features (e.g. hair color, glasses, smile)
- By sampling and interpolating in latent space, can generate new faces or smoothly morph one face into another.
Anomaly Detection Example
- Train a VAE on normal sensor data.
- When fed unusual data, reconstruction error will be high.
- Use this for fault detection in machines, fraud detction, etc.
Autoencoder
- Encoder
- Input Layer: takes in the original data
- Hidden Layer: These layers progrssively reduce the dimensionality of the input through operations like linear transformations and non-linear activations. (e.g., ReLU-Rectified Linear Unit)
- Ouput Layer: Produces the final latent represntation. Sometimes Sigmoid or Tanh are used depending on the nature of the input data.
- Learns to capture meaningful patterns in the data by minimizaing reconstruction loss, which mesures the difference between the original input and the reconstructed output produced by the decoder.
- Decoder
- typically mirrors the structure of the encoder but in reverse.
- During trainng, Mean squared Error (MSE) for continuous data or Binary Cross-Entropy (BCE) for binary data are commonly used to quantify the reconstruction loss.
Image Reconstuction Example
- input: 28x28 pixel
- encoder: compresses it to just 16 numbers (latent vector)
- decoder: expands those 16 numbers back into a 28x28 image
- result: the reconstructed digit looks similar to the original but not in the training set.
Denoising Images
- input: a noisy photo of a cat
- encoder: learns to ignore the noise and compress meaningful features.
- decoder: rebuilds the image without the noise.
- output: a clearer cat image.
Loss function
- Reconstruction loss: Ensure output similar to input
- KL divergence loss: Push the learned distribution to be close to a standard normal distribution. (can sample new data)
Generative Adversarial Network, GAN
- Generator: Learns to generate fake (generated) data that resembles data distribution.
- Discriminator: Learns to distinguish between real data and data generated by the Generator.
- Steps
- Generator creates fake data samples fro mrandom input (noise).
- Discriminator evaludates these samples together with real data samples.
- Discriminator outputs probabilities indicatcing whether each sample is real or fake.
- Based on the prediction of the Discriminator, the Generator and Discriminator are updated using specific loss functions.
- Applications
- Labels to Street Scenes
- Labels to Facade
- BW to Color
- Aerial to Map
- Day to Nihght
- Edges to Photo
- Text-to-Image Synthesis
Autoregressive Models
- a class of generative models where the current value of a time series is expressed as a linear function of its own past values plus some noise.
- foundational in generative AI and widely used in generative AI, particularly for tasks like text generation, speech synthesis.
- Examples
- GPT series: state-of-the-art autoregressive language models used for text generation.
- WaveNet: an autoregressive model for generating high-quality audio by predicting each sample conditioned on previous samples.
Training Autoregressive Models
- Pretraining
- the model sees sequences of tokens and learns to guess the next token.
- objective: minimize cross-entropy loss between its guess and the true next token.
- this teaches grammar, facts, reasoning patterns, and style from raw text.
- Supervised fine-tuning (optional)
- smaller curated datasets (questions to answer, instructions to respond) teach it to follow directions.
- Reinforcement learning from Human Feedback (optional)
- Humans rank multiple model outputs; a reward model is trained on those rankings; GPT is then optimized to produce higher-reward responses (safer, more helpful, less toxic)
- Text to Tokens via a tokenizer (e.g. BPE, Byte Pair Encoding)
- Each token becomes a vector (Embedding)
- Positional encodings inject order information.
- Transformer layer
- self-attention: each token looks at all previous token (causal mask) and decides which ones matter, computing weighted combinations.
- Multiple heads let it attend to different patterns (syntax, long-range links, etc.).
- feed-forward network: a nonlinear MLP refines each token's representation.
- residual connections & layer norm stabilize tranining.
Interfence
- a prompt (the context)
- GPT computes probabiliites for the next token.
- A decoding stragety samples a token
- Decoding knobs
- Greedy: take the top token
- Top-K
- Nucleus (Top-p) sampling (limit to likely options)
- Temperature scales randomness, controls how random the next token choice is
- lower = more determistic, higher = more creative
- Decoding knobs
- append the token and repeat autoregressive generation.