ir part 1 - github pages · classic search model information need query search engine results ......

46
Information Retrieval

Upload: others

Post on 21-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Information Retrieval

Page 2: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

ค้นคืน คือ ค้นอะไร คืนอะไร

• วิธีการใช้ Dictionary บน Python

• หนังสือเรื่อง อยู่กับก๋ง

• อีเมล์เชิญไปสัมภาษณ์งาน

• รูปภาพของเฌอปราง

• รถไฟฟ้าเปิดกี่โมง

Page 3: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Information Retrieval การค้นคืนข้อมูล

• การค้นหาเนื้อหาจากกองข้อมูลที่ตอบโจทยค์วามต้องการทางข้อมูล (Information need)

Te R.
Te R.
Te R.
Page 4: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Classic Search Model

Information Need

Query

Search Engine

Results

Documentcollection

Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 5: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

NLP + Information Retrieval

• "รถไฟฟ้าเปิดกี่โมง" --->

• "รถไฟฟ้าเปิดกี่โมง" ---> รถไฟฟ้า BTS สายสุขุมวิทเปิดเวลา 5:15

Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 6: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:
Te R.
Page 7: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Document เอกสาร

• วิธีการใช้ Dictionary บน Python

• หนังสือเรื่อง อยู่กับก๋ง

• อีเมล์เชิญไปสัมภาษณ์งาน

• รูปภาพของเฌอปราง

• รถไฟฟ้าเปิดกี่โมง

Te R.
Te R.
Te R.
Page 8: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:
Te R.
Te R.
Te R.
Page 9: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Challenges

• ทําความเข้าใจ query และ document เพื่อสนองความต้องการทาง

ข้อมูลของผู้ใช้

• ต้องทําให้ได้เร็ว (อย่าเกิน 1-2 วินาที)

• ต้องอย่าเปลืองที่เก็บข้อมูลและเครื่องคอมพ์

Page 10: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Boolean Retrieval

Page 11: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Search แบบง่ายสุด

• อยากหาไฟล์ที่มีคําว่า Caesar และคําว่า Brutusgrep 'Caesar' docs/*.txt | grep 'Brutus'

• อยากหาไฟล์ที่มีคําว่า Caesar และ Brutus แต่ไม่มีคําว่า Calpurnia

Te R.
Te R.
Te R.
Te R.
Page 12: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 13: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Term-Doc Matrix ในความเป็นจริง

• N = 1 ล้าน document แต่ละ doc มี 1000 คํา

• ค่าเก็บข้อมูล

• ตัวอักษรละ 1 byte คํานึงมีประมาณ 6 ตัวอักษรโดยเฉลี่ย

• ต้องใช้ Hard drive ขนาด 1 byte x 6 x 1000 x 1M = 6000MB = 6GB

• ค่าเก็บข้อมูล term-doc matrix

Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 14: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

• 4 bytes x 1M document x 100,000 (vocab size) = 400GB 99% ของ 400GB เก็บแต่ 0 เอาไว้

Te R.
Te R.
Te R.
Te R.
Te R.
Page 15: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Inverted Index

Page 16: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Inverted Index

• datat structure ที่เป็น sparse matrix แบบหนึ่ง search engine

ทุกประเภทบนโลกนี้ยังใช้กันอยู่

• จุดมุ่งหมาย คือ ประหยัดที่และประหยัดเวลา

Page 17: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Inverted Index

Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 18: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:
Te R.
Te R.
Te R.
Te R.
Te R.
Page 19: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:
Te R.
Te R.
Te R.
Te R.
Te R.
Page 20: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 21: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Brutus and Calpurnia

Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 22: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:
Te R.
Te R.
Page 23: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Linguistic Processing of Documents

Page 24: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

From words to terms

• แปลงเอกสาร (e.g. email, PDF, word doc) ให้เป็น text file ธรรมดา

• Tokenize: honey-roasted pork

• Normalization: U.S.A, USA —> usa; naïve, naive —> naive

• Stemming: authorization, authorize, authorized —> authoriz

• Stopwords: the, a, to, of, in —> X

Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 25: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Tokenize ภาษาไทย: ผลิตรายการ

• Word segmentation with Machine Learning : ผลิต, รายการ

• Dictionary : ผลิต, ราย, การ, ลิตร

• Character cluster: ผลิต, ราย, การ

• Character ngrams: ผล ลิต ตร รา ยก กา ผลิ ลิตร ตรา ราย ยาก การ

Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 26: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Thai Character Cluster

Page 27: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

From words to terms

• แปลงเอกสาร (e.g. email, PDF, word doc) ให้เป็น text file ธรรมดา

• Tokenize

• Normalization

• Stemming

• Stopwords

Page 28: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Phrase Queries

Page 29: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Phrase Query

• หา document ที่มีคําว่า Stanford University อยู่ติดกัน

• ไม่เอา doc "I went to university at Stanford"

Page 30: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:
Page 31: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Phrase query ที่ยาวกว่า 2 คํา

• Stanford University Palo Alto —>"Stanford University" AND "University Palo" AND "Palo Alto"

Page 32: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Biword Index ไม่ใช่คําตอบ

• Index จะใหญ่เบิ้มมากเสียค่าเก็บ (อย่าลืมว่า RAM แพง)

• ไม่รองรับ phrase ที่ยาวกว่าสองคํา

Page 33: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Positional Index

• (term, freq): [docID, docID, docID, …]

• (term, freq): [docID: [word position, word position, …] , docID: [word position, word position, …] , … ]

Page 34: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:
Page 35: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Positional Index แพงไปมั้ย

Page 36: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

สรุป

• ใช้ทั้งสองอย่างไปเลย

• positional index มันช้า ==> phrase ไหนที่เจอบ่อยๆ ก็เก็บไว้ใน

phrase index (caching)

Page 37: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Ranked Retrieval with TF-IDF

Page 38: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Boolean Search

• ไม่เข้า ก็ออกเลย

• ไม่เยอะไป (ขี้เกียจเปิดอ่านหมด) ก็น้อยไป (ไม่มีสิ่งที่อยากได้)

Page 39: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:
Page 40: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Relevance Score คะแนนความเกี่ยวข้อง

score(d1,q)=0.81

score(d2,q)=0.74

score(d3,q)=0.68

q=คณะอักษรศาสตร์

Page 41: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

ถ้าเห็น term นั้นบ่อย doc นั้นยิ่งคะแนนเยอะ

q=AnthonyBrutus

Page 42: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

Term Frequency

• Frequency = Occurrence =

จํานวนครั้งที่เจอ

• f

• tft,d = จํานวนครั้งที่เจอ t ใน d

Page 43: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

คําทุกคําไม่ได้เท่าเทียมกัน

• term ที่เห็นบ่อยๆ มักจะไม่ค่อย informative (ไม่ได้ช่วยให้หา

document ได้แม่นยําขึ้น)

• tft,d = ความสําคัญของ term นั้นต่อ document นั้น

• ความสําคัญของ term นั้นโดยทั่วไป?

Page 44: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:
Page 45: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:
Page 46: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย:

TF-IDF weighting