Skip to content

Commit 29a7865

Browse files
authored
Merge pull request #36 from HamedDaneshvar/refactor
refactor: refactor SMILE image editing
2 parents 750602d + b42274f commit 29a7865

4 files changed

Lines changed: 2263 additions & 2726 deletions

File tree

examples/Large_Language_Models/llm_gsmile_openai.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ def query_gpt_for_perturbations(
288288
# Word2Vec model
289289
# --------------------------------------------------------------------------- #
290290

291-
# TODO: anything you want to do
292-
# Improving and using better Word2Vec Models and also giving user an option to have preference on this
291+
# TODO: Improving and using better Word2Vec Models and also giving user an option
292+
# to have preference on this
293293

294294
def load_google_news_vectors():
295295
# First try gensim downloader (fastest & simplest)
@@ -339,11 +339,11 @@ def clean_text(text: str) -> str:
339339
cleaned = re.sub(r"[^\w\s]", "", text.lower())
340340
return cleaned.strip()
341341

342-
# TODO: anything you want to do
343-
# Removing the word "safe" from the function
342+
# TODO: Removing the word "safe" from the function
344343
# Adding More statistical distances here
345344
# As Statistical distance measures are the code for SMILE, we can consider a separate class for them.
346345

346+
347347
def safe_wmdistance(model, text1: str, text2: str) -> float:
348348
"""Compute Word Mover's Distance using only in-vocabulary cleaned words.
349349
@@ -418,8 +418,7 @@ def normalize_similarities(wmd_scores: list) -> list:
418418
# Regression
419419
# --------------------------------------------------------------------------- #
420420

421-
# TODO: anything you want to do
422-
# This part can be extended to cover other types of LIME, like BayLIME
421+
# TODO: This part can be extended to cover other types of LIME, like BayLIME
423422

424423
def fit_weighted_regression(
425424
perturbations: list,

0 commit comments

Comments
 (0)