使用 TF-IDF 或 Word2Vec 从职位描述中提取技能

Extracting skills from a job description using TF-IDF or Word2Vec

我有一种情况需要从可用的职位描述中提取正在申请工作的特定申请人的技能,并将其完全存储为一个新列。 数据框 X 如下所示:

Job_ID        Job_Desc 
1             Applicant should posses technical capabilities including proficient knowledge of python and SQL
2             Applicant should posses technical capabilities including proficient knowledge of python and SQL and R

结果输出应如下所示:

Job_ID       Skills
1            Python,SQL
2            Python,SQL,R

我已经使用 tf-idf count vectorizer 来获取 Job_Desc 列中最重要的单词,但我仍然无法在输出中获取所需的技能数据。这可以通过使用 skip gram 或 CBOW 模型的 Word2Vec 以某种方式实现吗?

我的代码如下所示:

from sklearn.feature_extraction.text import CountVectorizer
cv=CountVectorizer(max_df=0.50)
word_count_vector=cv.fit_transform(X)

from sklearn.feature_extraction.text import TfidfTransformer
tfidf_transformer=TfidfTransformer(smooth_idf=True,use_idf=True)
tfidf_transformer.fit(word_count_vector)

def sort_coo(coo_matrix):
tuples = zip(coo_matrix.col, coo_matrix.data)
return sorted(tuples, key=lambda x: (x[1], x[0]), reverse=True)

def extract_topn_from_vector(feature_names, sorted_items, topn=10):
"""get the feature names and tf-idf score of top n items"""

#use only topn items from vector
sorted_items = sorted_items[:topn]

score_vals = []
feature_vals = []

for idx, score in sorted_items:
    fname = feature_names[idx]

    #keep track of feature name and its corresponding score
    score_vals.append(round(score, 3))
    feature_vals.append(feature_names[idx])

#create a tuples of feature,score
#results = zip(feature_vals,score_vals)
results= {}
for idx in range(len(feature_vals)):
    results[feature_vals[idx]]=score_vals[idx]

return results

feature_names=cv.get_feature_names()
doc=X[0]

tf_idf_vector=tfidf_transformer.transform(cv.transform([doc]))
sorted_items=sort_coo(tf_idf_vector.tocoo())
keywords=extract_topn_from_vector(feature_names,sorted_items,10)
print("\n=====Title=====")
print(X[0])
print("\n===Keywords===")
for k in keywords:
   print(k,keywords[k])

我想不出有什么方法可以让 TF-IDF、Word2Vec 或其他 simple/unsupervised 算法单独识别您需要的 'skills' 类型。

您可能需要大量手工策划的技能列表 – 至少,作为一种自动评估旨在提取技能的方法的方法。

有了精选列表,Word2Vec 之类的东西可能有助于建议同义词、替代形式或相关技能。 (对于已知的技能 X,以及文本中的大型 Word2Vec 模型,与 X 相似的术语可能是相似的技能——但不能保证,所以你可能仍然需要人类 review/curation。)

使用足够大的数据集将文本映射到结果——比如,候选人描述文本(简历)映射到是否是人工审阅者选择他们进行面试,或者雇用了他们,或者他们在一份工作中取得了成功,您或许能够识别出高度预测适合特定工作角色的术语。这些条款可能通常是事实上的 'skills'。但是发现这些相关性可能是一个更大的学习项目。

这里 a paper 提出了一种类似于您所建议的方法。

它建议使用 LSTM + 词嵌入的组合(无论它们来自 word2vec、BERT 等) 由于 TF-IDF 计算重要性的方式,您可能不会获得很好的结果。技能很可能只提到一次,而且帖子很短,所以很多其他用到的词也很可能只提到一次。

正如本文所建议的,您可能需要从标记为技能或非技能的职位发布中创建文本训练数据集。