Wednesday, March 13, 2024

Unleashing the Potential: Modern Techniques to Boost Large Language Model Performance

Large Language Models (LLMs) have taken the AI world by storm, demonstrating remarkable capabilities in tasks ranging from text generation to code creation. But like any powerful tool, LLMs have room for optimization. Researchers are constantly exploring new techniques to push the boundaries of LLM performance and unlock their full potential. In this introductory blog post, we'll delve into some of the most promising approaches that are shaping the future of LLMs.

1. Retrieval-Augmented Generation (RAG):

Imagine an LLM that can not only generate text but also access and leverage relevant information from external sources. This is the core idea behind RAG models. RAG combines an LLM with a retrieval system that fetches information pertinent to the task at hand. The LLM then utilizes this retrieved information to enhance its generation process, leading to more factually accurate and informative outputs.

2. Chaining Transformers:

LLMs are often monolithic beasts, tackling entire tasks in one go. Chaining Transformers breaks down complex tasks into smaller, more manageable subtasks. Each subtask is handled by a specialized transformer model, and the outputs are sequentially chained together to achieve the final goal. This approach allows for more efficient training and potentially better performance on intricate tasks.

3. Prompt Engineering:

Think of prompts as instructions that guide an LLM towards the desired outcome. Prompt engineering focuses on crafting effective prompts that steer the LLM in the right direction. By carefully designing prompts that incorporate task-specific information and desired outcomes, researchers can significantly improve the quality and accuracy of LLM outputs.

4. Transfer Learning and Fine-tuning:

Pre-trained LLMs have learned a wealth of knowledge from massive datasets. Transfer learning and fine-tuning techniques leverage this pre-trained knowledge as a starting point for new tasks. By fine-tuning an LLM on a task-specific dataset, researchers can significantly reduce training time and improve performance compared to training from scratch.

This blog post has just scratched the surface of the exciting advancements in LLM technology. In future posts, we'll delve deeper into each of these techniques, exploring their specific applications and showcasing their potential to revolutionize various AI domains. 

Wednesday, October 19, 2022

Easy setup Kibana Nginx reverse proxy with Ansible

Motivation

Amazon OpenSearch Service cluster instance run inside a virtual private cloud. If you want to access Kibana dedicated to this instance you have two options. One is tunneling to EC2 bastion host which is realitvely straightforward. One of the disadvantages of this approach is that you need to share your bastion host keys to clients. Another is reverse proxy on bastion host to private OpenSearch Kibana. In this example, we are going to show how you can setup access to Kibana using Nginx reverse proxy and provision it with Ansible.

This example represent basic setup which can serve as basis for future improvements. This basis don't include secure access configuration (certifications, authentication). It uses HTTP between client and proxy server, for production environment using HTTPS is recommended in this context. It's an easier setup, but for other hand it's also less secure setup.

Example

Inventory

First you need to have inventory defined with one variable (open_search_endpoint) which should point to Kibana instance. Notice, we have two ec2 instances in our inventory. One can be for production environment, second for staging for example. 

Main playbook

Next we are going to define main Ansible playbook, which is pretty straight forward. For it to work, you need to have configuration files (default.config and ngnix.config) located in your path.

Default configuration

For default.config, we are using simple proxy pass. If you want more secure connection, this is where you would configure HTTPS.

Nginx configuration

Thursday, August 4, 2022

Serverless React, AWS Lambda and API Gateway example

Here is small terraform example how you can create serverless React app that will use AWS API Gateway which will call AWS Lambda

API Gateway is proxying GET request to lambda. Lambda will simply return "Hello World". 


Actual terraform infrastructure definition. This terraform definition include CORS configuration.


Lambda which that will return "Hello World".

Thursday, April 28, 2022

ALB rule based routing with terraform

From 2017 Amazon started supporting Host-based routing on Application Load Balancer. Content-based routing was supported before, so Application Load Balancer now supports both Host- and Path-based rules. You can combine both routing types to create complex rules for your services. If you are looking how to combine both routing types, please look at this stack overflow answer: https://stackoverflow.com/a/46304567.

In this example we are going to show you how you can use a single Application Load Balancer(ALB) for separate ECS’s. Imagine, you have 30 ECS’s running on Fargate. You want 10 of those to be exposed. If you would use ALB for every single ECS, this would be very inefficient and expensive. To combat this, AWS supports routing traffic on ALB to Target Groups (ECS can be one example of a target group) based on rules. In this way, you can have one ALB which will route traffic to the Target Group (in our example this will be ECS). 

Below is one example of how you can do that with comments about specific details.

Tuesday, January 28, 2020

React.js PDF export

If you need to eport React.JS components to PDF, this is one way how to do it. This approach uses html2canvas to generated canvas objects, then uses pdfMake to export them to PDF. You need to add ids to components you want to export:


Saturday, March 2, 2019

Python script to find structure of opportunities on Slovakia job market

Introduction


I will try to answer this simple question using google colab + python notebook + web crawling Slovak job ad site + simple NLP (mainly using regex and simple text transformations) and pandas with sklearn.

It's impossible to answer this question using something like TIOBE programming index. This index is composed using trend searches in popular search engines. It doesn't take into consideration what is actual demand for some programming language on job market, let alone niche market like Slovak.

How is this possible?


This is possible now due to change of law on Slovak job market, which basically force companies to publish lowest possible salary they are willing to pay for position. Companies tends to put higher figures in ads, to compete with each other. So real salaries are bit higher, but it should average itself out. There is one problem tough. There is no regulation what type of salary they should put on ad, so there are companies that put net salary and other put gross salary. But. there are not so many of those that put gross salaries.

Data


For correctness, jobs with salary lower than 900 and bigger than 5500 EUR will be ignored, because there is higher probability they are false positive.

We will crawl most popular Slovak job ad site. Crawler will crawl through roughly 1200 pages of IT jobs. Some of which are full programming jobs, others are something in between (Managers, Support, Testers)

We will use corpus of words that will represent most popular programming languages. There will be tree different strategies for parsing programming languages from ad text. You shouldn't worry to much about this. Main reason for this it's difficulty to parse words like "C" or "R" programming languages from ad text, so we must treat it as single word that have no word boundaries.

Python scripts

Here is link to read only google colab python notebook without crawl code (code that actually rip/downloads content from job ad site)

Click here to see the scripts


Summary


As you can see there are some interesting surprises. Java is main language to learn if you want to make between 3000 and 4000 Euros.

Who knew bash is so important to learn? But on other hand is not so hard to learn it. :)

For lower paying positions PHP is main language, but you can also see there R at second spot (maybe some error in parsing?)

It no surprise that for higher salaries than 4000 EUR there is no clear winner. You must be generalist at these positions (Architects, Team Leads, Tech Leads). So answer to the question in title is: None, or there is not silver bullet, just be good at what you do and make sure to learn as much as you can.

Monday, August 13, 2018

Serverless Architectures

Serverless Architectures 


SA are new approach to application designs. This is hot topic in the software architecture world right now. All "Big Three" (Amazon, Google, Microsoft) are heavily investing in "Serverlessnes" right now.

What is it?

Unlike traditional architectures (where application run on server) it’s run in stateless compute containers that are event-triggered, ephemeral (may only last for one invocation), and fully managed by a third party. These are typically “rich client” applications—think single-page web apps, or mobile apps. These apps use vast ecosystem of cloud-accessible databases authentication services (e.g., Auth0, AWS Cognito), and so on. But if you need computation, you can use for example AWS Lambdas or Azure Functions.

Upsides and downsides

Upsides:

  • No need for system administration (everything is handled by third party)
  • Decreases complexity of your product
  • Natively micro service architecture. 
  • Lesser cost to scale.
  • Elasticity - native scaling 
  • Smaller development and operational costs
  • Decrease time to market

Downsides:

  • Debugging and monitoring is still and issue.
  • Tooling is not there quite yet.
  • Cold start issues.





Tuesday, March 27, 2018

Truffle execute external script call contract function

errors:

 * Error: VM Exception while processing transaction: out of gas
 * Error: Cannot create instance of YourContract; no code at address
 * Error: sender account not recognized
 * Error: invalid address

If you get some of these errors while trying to execute contract function from truffle script, here is proper way to do it:

Monday, March 26, 2018

Truffle external scripts working example

If you getting errors bellow while trying to execute your truffle external script continue to read.

errors:

TypeError: Cannot read property 'apply' of undefined 

exception at require.js:128:1 

TypeError: fn is not a function 

For some reason it was quite difficult to find solution how to run external script. After some time I finally have figure it out so I'm sharing it with world:


Thursday, March 22, 2018

Smart Contracts and Ethereum solidity

WHAT ARE SMART CONTRACTS?

I have opportunity to work on interesting smart contract project. In that respect I decided that I will write something about this _hot topic on my blog. So, what's smart contract anyways?

In 1994, Nick Szabo, a legal scholar, and cryptographer, realized that the decentralized ledger could be used for smart contracts, otherwise called self-executing contracts, blockchain contracts, or digital contracts. In this format, contracts could be converted to computer code, stored and replicated on the system and supervised by the network of computers that run the blockchain. This would also result in ledger feedback such as transferring money and receiving the product or service.

Smart contracts help you exchange money, property, shares, or anything of value in a transparent, conflict-free way while avoiding the services of a middleman.

Can laws be written on smart contacts. What world would that be? Programmers will become lawyers? Imagine code reviews and testing on that contracts.

HOW ARE THIS CONTRACT EXECUTED


Most smart contracts written today are based on Ethereum blockchain. Ethereum blockchain is world computer that can execute smart contracts. Smart contracts are written in language called Solidity (current version is: 0.4.21). Most popular framework to work with smart contract is called Truffle. Contracts are serving as back-end for application, and front-end is written using web3. Web3 is new way of building web apps called decentralized web. Basically there is no classical back-end, only front-end with decentralized smart contracts.