Approximation in LLM
Approximation is a pivotal concept in various fields, including mathematics, programming, and machine learning. It involves creating simplified models or functions that closely resemble more complex or unknown functions, allowing for efficient computation and analysis. This wiki entry synthesizes discussions from multiple sources to provide a comprehensive understanding of approximation.
Approximation in Geometry and Programming
In the context of geometry and programming, approximation is often used to simplify complex functions or datasets. This is achieved by substituting a function with a polynomial that closely resembles the original function, which is computationally cheaper to evaluate.
Methods of Approximation
Polynomial Approximation
Polynomial approximation is a common method where a function is represented as a polynomial. Techniques such as the Maclaurin and Taylor series are used to expand a function into an infinite sum of terms derived from its derivatives at a specific point. This method is particularly useful for differentiable functions.
Curve Fitting
Curve fitting is another approximation technique used to model data by fitting a curve that represents the general trend of the data points. Although inherently imprecise, it is useful for visualizing overall trends, such as temperature changes over time.
Visualizing Approximation](https://livebook.manning.com/book/geometry-for-programmers/chapter-6/116)
Figures such as Figure 6.10 and Figure 6.33 illustrate how approximation can be visualized. These figures show how adding more terms to a polynomial approximation can make it more accurate and how approximation can model temperature data trends.
Figure 6.10 With more members coming, the approximation gets closer to the original function.
Figure 6.33 It gets warmer in the middle of the day, but then it gets cold again.
Practical Implementation: Computing an Approximating Polynomial](https://livebook.manning.com/book/geometry-for-programmers/chapter-6/394)
An example of computing an approximating polynomial using Python's sympy library is provided in Listing 6.3. This code demonstrates a least-squares method to fit a polynomial to a set of data points, iteratively adjusting coefficients to minimize the difference between the polynomial and the data points.
from sympy import *
xs = [10, 11, 12, 13, 14]
ys = [-42, -41, -38, -37, -37]
N = len(xs)
M = 2
LS = Matrix([[sum([xs[k]**(i+j) for k in range(N)])
for j in range(M+1)]
for i in range(M+1)])
B = Matrix([sum([ys[k]*(xs[k]**i) for k in range(N)])
for i in range(M+1)])
last_point_reentrance = 0
a = [0, 0, 0]
def P(x, a):
return sum([a[i]*x**i for i in range(len(a))])
precision = 0.01
while abs(P(xs[N-1], a) - ys[N-1]) > precision: #1
LS_more = Matrix([[last_point_reentrance*xs[N-1]**(i+j)
for j in range(M+1)]
for i in range(M+1)])
B_more = Matrix([last_point_reentrance*ys[N-1]*xs[N-1]**i
for i in range(M+1)])
a0, a1, a2 = symbols('a0 a1 a2')
Pol = Matrix([a0, a1, a2])
solution = solve((LS+LS_more)*Pol - (B+B_more), (a0, a1, a2))
a = [value for key, value in solution.items()]
last_point_reentrance += 1 #2
#1 The algorithm tries adding the last point again and again until the precision expectations are met.
#2 On each iteration, exactly one new last point is added. But you can add more if you want the algorithm to converge faster.
Approximation in Deep Learning
In deep learning, approximation is crucial for creating models that serve as proxies to unknown or complex transformations. This enables predictions, classifications, or estimations based on available data.
Function Approximation
Function approximation involves designing a model function with tunable parameters to approximate an unknown transformation function. This is essential in tasks like classification or estimation, where the true function is unknown, and data guides the learning process.
Taylor Series Approximation
In optimization and loss function estimation, approximation is often achieved using a Taylor series. This method expresses a function in terms of its derivatives at a specific point, aiding in gradient-based optimization methods by approximating the loss function to determine parameter updates.
Singular Value Decomposition (SVD) Approximation
SVD approximation is a matrix factorization technique that reduces the rank of a matrix to capture significant patterns while discarding noise. This process aids in dimensionality reduction and data compression, making it easier to handle large datasets while preserving essential information.
In summary, approximation is a versatile tool across various domains, enabling efficient computation, data modeling, and learning from complex datasets.
| Book Title | Usage of Approximation | Technical Depth | Connections to Other Concepts | Examples Used | Practical Application |
|------------|------------------------|-----------------|-------------------------------|---------------|-----------------------|
| [Geometry for Programmers](https://www.manning.com/books/geometry-for-programmers) | Discusses approximation in the context of substituting complex functions with polynomials for better computational performance. | Explores polynomial approximation, Maclaurin and Taylor series, and curve fitting. | Connects to data modeling and visualization, showing trends in datasets. | Uses figures to illustrate polynomial approximation and temperature data modeling. | Provides Python code for computing approximating polynomials using least-squares method. [more](https://livebook.manning.com/book/geometry-for-programmers/chapter-6/1) |
| [Math and Architectures of Deep Learning](https://www.manning.com/books/math-and-architectures-of-deep-learning) | Focuses on approximation in deep learning for creating models that act as proxies for unknown transformations. | Covers function approximation, Taylor series for optimization, and SVD for matrix factorization. | Links approximation to optimization, loss function estimation, and dimensionality reduction. | Discusses Taylor series and SVD in the context of deep learning tasks. | Highlights approximation's role in model learning, optimization, and data compression. [more](https://livebook.manning.com/book/math-and-architectures-of-deep-learning/chapter-1/46) |
FAQ (Frequently asked questions)
What is approximation in the context of polynomial functions?
What methods are used to approximate functions with polynomials?
How does adding more terms affect the approximation of a function?
What is the purpose of approximation in data modeling?
How is approximation applied in modeling temperature data?
What does Figure 6.33 illustrate about temperature changes?
How is an approximating polynomial computed in the given code?
What is the role of the 'last_point_reentrance' variable in the code?
What is the goal of approximation in mathematics?
What methods can be used for approximation?