Posts

Showing posts with the label Notes

How a language model learns: pretraining and fine-tuning — Part 2

Image
A language model can get a training target from the same text it is reading. Move the text over by one token: each input position now has a next token to predict. No one has to write a separate answer for every prefix. The catch is that the model must not be allowed to peek at that answer. The text already contains a training target Consider the sentence “The kettle is on the stove.” As before, we will pretend each word is one token and leave out punctuation. A real tokenizer may split it differently. After “The”, the next token in this sentence is “kettle”. After “The kettle”, it is “is”. Each position gives us a prediction to compare with the token that actually follows. The input and target sequences are offset by one position. Word-sized tokens are a simplification for this example. This is why we can train a language model from ordinary text without manually writing an answer for every prefix. The text supplies the target. However, later tokens are present in the training s...

Inside a language model: from text to the next token — Part 1

Image
A language model can use a sentence you just typed without learning new weights from it. The prompt changes the calculation's input. During ordinary generation, the model's learned numbers stay fixed. To see how that works, give it the words “The kettle is on the” and follow one prediction. We will follow a model in the GPT family, short for Generative Pre-trained Transformer. It generates text using already-learned parameters: the numbers its calculations use. We will trace one prediction through that model, then see how repeating the step produces more text. The second article explains how training learns those numbers. Start with one prediction After “The kettle is on the”, “stove” is a possible continuation. So is “table”. The model assigns scores to the possible next tokens, which we can turn into probabilities. Choosing a token from those probabilities is a separate step. A token is a unit of text defined by a tokenizer. It might be a word, part of a word, or punctua...

specs 2, Scala and maven with IntelliJ 12.1 and getting things right

Recently, to learn a test framework for Scala ( even for Java) I chose specs2 .  Its still difficult to move to SBT, largely due to the fact that I am yet to be comfortable using it. So, for the time being I will stick to maven. To configure the scala/java project edit the pom.xml to include <dependencies> <!-- specs2 version I used : 1.12.3--> <dependency> <groupid>org.specs2</groupid> <artifactid>specs2_${scala.version}</artifactid> <version>${specs2.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>${scala.version}</version> </dependency> </dependencies> <build> <sourceDirectory>src/main/scala...

getting android emulator to work normally on 64 bit linux

Recently I started working on a nfc android app but I was stuck with very basic thing of getting emulator to work normally on my home laptop running Linux Mint. I tried numerous ways to configure eclipse, java paths, AVDs (android virtual devices), checking adb logcat etc but nothing really helped. The emulator could start but always hanged on the boot screen. (believe me, I even waited a complete day for it to boot up). Thanks to StackOverflow again! As described in the comments here  and also here , the Android team still has some more work to do until they make the emulator ( and other stuff) work with 64-bit version of java. But, I could happily run my android project with emulator ( which works quite fast now :) ) by simply configuring eclipse's default jre to be a 32-bit version of java 7. While 64 bit jdk being default for other things. 

Migrating svn repository to git

After googling I found this StackOverflow  link . First, I needed to install git-svn module. $ sudo apt-get install git-svn Now we also need to map svn users to git users. we can get all svn users  ( skip if you already know them) with this command ( execute under svn project root ) $ svn log | grep '^r[0-9]' | awk '{print $3}' | sort | uniq Once you get all users, create a users.txt file mapping svn users to git user1 = first_name last_lame <email@address.com> user2 = first_name last_lame <email@address.com> Once you make sure all of your svn users are mapped to git, then execute $ git svn clone --stdlayout --no-metadata -A users.txt svn://hostname/path dest_dir It will start fetching svn repository into git. If you run into other problems, like Author: (no author) not defined in users.txt file then simply add following line to users.txt (no author) = first_name last_lame <email@address.com> Note : If, due to this error, git svn comm...

Setting up Own Maven Repository

<settings> <mirrors> <mirror> <!--This sends everything else to /public --> <id>nexus</id> <mirrorof>*</mirrorof> <url>http://myhost.com:8080/nexus/content/groups/public</url> </mirror> </mirrors> <profiles> <profile> <id>rakuten</id> <repositories> <repository> <id>myprofile</id> <name>My Internal Repository</name> <releases> <enabled>true</enabled> <updatepolicy>never</updatepolicy> </releases> <snapshots> <enabled>true</enabled> <updatepolicy>always</updatepolicy> </snapshots> <url>http://myhost.com:8080/nexus/content/groups/public</url> <layout>default</layout> </repository>...

How To: Successfully set up Amazon EC2 micro instance

Amazon Web Services is a very rich arsenal of web services. Surprisingly, using them is really easy and simple. I tried my first hands on Amazon's Elastic Cloud, in layman's terms, it is a server I tried to set up a AWS micro instance on Amazon EC2. The setup is very simple and we can set a system running in just few minutes. I could also quickly set up a tomcat server running on it. I will quickly list down the steps that I followed. (1) From EC2 console launch a new Instance. For quick start select any AMI ( Amazon Machine Image) that suits your need. It can later be changed or upgraded. (2) Once an AMI is selected, fill in the details related to instances (Micro instance's usage falls under free tier for the first year), kernel, ram, monitoring details etc. (3) Next, create a key-value (optional) (4) Select proper security group. (This is also important to keep your instance secure. Once I got my instance hacked due to careless firewall settings ). Don't ...

A note on dictionaries in Programming languages

I recently started with learning python. The good thing about python is that everything in python is dynamic. Python is dynamically typed language. What does it means? In C/C++ or Java we need to define the type of a variable before using it. int a; float b; // even Objects need to be defined in Matrix m1; But, python is different in this regard. Here, we can use a variable and its type is decided on first assignment. list # not needed but just for explanation list = [] # creates an empty list Thus, Python decides the type of a variable on its first assignment making it dynamically typed. But, another thing to be careful with in it is that Python is also strongly typed language. Means, once assigned we cant change the type of that variable. In, above python code once list varible is assigned an list object it cant be assigned any other data type. It remains list. Below, is the summarization of different types of languages based on the property we just discussed. stat...

line-by-line processing : Linux Bash

Often we require to process a file content line by line. Linux inherently supports this thorough its powerful shell commands. Lets walk through some of the ways to parse a file line-by-line. First, we can parse a file by catting a file and piping the file output to a while read loop. The following bash script produces it own code as output. Isn't it interesting? code for dumping own file content #!bin/bash cat $0 | while read line do echo $line; done Secondly, using file descriptors we can play a lot with it. But, before we will learn about firl descriptors in brief. Under unix/linux OS, files are referenced, copied, and moved by unique numbers known as file descriptors. 0 stdin It is(devie) usually the keyboard or mouse from where the input comes. 1 stdout It is where output is redirected e.g. screen or file 2 stderr It is where the standard error messages are routed by commands, programs, and scripts. $ some_command 2>&1 this means, the command sends all of ...

Upgrading Ubuntu to Natty Narwhal

I recently upgraded Maverick Meerkat to Natty Narwhal. The new ubuntu is packed with Unity for default desktop session. The Unity brings a lot of improvements with it. Along with improved UI and perceivable improved speed we could see a new scrollbar which takes less space and looks nice. Real gift to Ubuntu lovers!! worth a try !!!

Removing packages from linux (ubuntu)

I tried to remove the packages from maverick (Ubuntu 10.10), today..and found some good ways to do it (A)First search the package : The traditional way: dpkg -l | grep partial-name-of-package-to-be-removed Using dpkg command ....more conspicuous way dpkg -l '* partial-name-of-package-to-be-removed *' For example, you want to remove jdk then dpkg -l '*jdk*' (B)There are two ways to remove packages: Using apt command : ...the better way... After getting the list of packages choose the appropriate one and run following command * To remove packages: sudo apt-get remove package-name * To remove packages and dependencies: sudo apt-get autoremove package-name * To remove packages, dependencies and configuration files: sudo apt-get purge package-name Using dpkg command : ...the crude way... * To remove packages: sudo dpkg -r package-name * To remove packages,and configuration files: sudo dpkg --purge package-name * To force removal, if got depe...

Install Vista / Win 7 from Pen Drive

Here is a cool trick(in fact, a built in utility in vista/win 7) to make a pen drive bootable and use it to install vista or win 7 from it. What you are required to have is a pen drive (4 GB+) and vista/win 7 iso/DVD and a laptop or a PC. :P So, if all is set we proceed, as follows: First, open cmd prompt as administrator. Then type following commands one by one. (Note: comments(#) are shown for the purpose of understanding and they are definitely not part of commands.) diskpart # Opens DISKPART utility built-in in vista/win 7 list disk # Lists the available disks for installation select disk 1 # select the disk 1 or 2 or 3 or so on.. i.e. pen drive disk which is there in the list clean # cleans the disk create partition primary # creates the primary partition select partition 1 # does as specified active #.... foramt fs=NTFS # format it with NTFS file system. it will take some time! :( assign # mounts the disk exit # get exit from diskpart utility Don’t close the cmd prompt as we n...